Skip to content

Commit 3da66ee

Browse files
authored
Merge pull request #187 from ChBrain/governance/restore-hofstede-hook-scripts
fix: restore hofstede pre-commit validator entrypoints
2 parents 0ac3860 + fb0fb1c commit 3da66ee

3 files changed

Lines changed: 90 additions & 1 deletion

File tree

.validation-stamp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1aed19f87d581fee9998440b212d8b155e31a72a
1+
95ccbd96b8dc49576a357f3905a7f1e5d960b80b

tests/validate_hofstede_derived.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""CLI wrapper for Hofstede derived-score validation.
2+
3+
Pre-commit passes changed culture file paths to this script. The script
4+
forwards them via PR-style env vars so tests/test_hofstede_derived.py
5+
validates only affected countries.
6+
"""
7+
from __future__ import annotations
8+
9+
import os
10+
import subprocess
11+
import sys
12+
from pathlib import Path
13+
14+
15+
def _norm(path: str) -> str:
16+
return path.replace("\\", "/")
17+
18+
19+
def main() -> int:
20+
changed = [_norm(p) for p in sys.argv[1:] if p.strip()]
21+
if not changed:
22+
return 0
23+
24+
env = os.environ.copy()
25+
env["PR_CHANGED_FILES"] = " ".join(changed)
26+
env["PR_DATA_CHANGED"] = "true" if any(p.startswith("data/") for p in changed) else "false"
27+
28+
result = subprocess.run(
29+
[sys.executable, "-m", "pytest", "-q", "tests/test_hofstede_derived.py"],
30+
capture_output=True,
31+
text=True,
32+
check=False,
33+
env=env,
34+
)
35+
36+
if result.returncode != 0:
37+
if result.stdout.strip():
38+
print(result.stdout.strip())
39+
if result.stderr.strip():
40+
print(result.stderr.strip())
41+
return result.returncode
42+
43+
44+
if __name__ == "__main__":
45+
raise SystemExit(main())
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""CLI wrapper for Hofstede reference-score validation.
2+
3+
Pre-commit passes changed culture file paths to this script. The script
4+
forwards them via PR-style env vars so tests/test_hofstede_reference.py
5+
validates only affected countries.
6+
"""
7+
from __future__ import annotations
8+
9+
import os
10+
import subprocess
11+
import sys
12+
13+
14+
def _norm(path: str) -> str:
15+
return path.replace("\\", "/")
16+
17+
18+
def main() -> int:
19+
changed = [_norm(p) for p in sys.argv[1:] if p.strip()]
20+
if not changed:
21+
return 0
22+
23+
env = os.environ.copy()
24+
env["PR_CHANGED_FILES"] = " ".join(changed)
25+
env["PR_DATA_CHANGED"] = "true" if any(p.startswith("data/") for p in changed) else "false"
26+
27+
result = subprocess.run(
28+
[sys.executable, "-m", "pytest", "-q", "tests/test_hofstede_reference.py"],
29+
capture_output=True,
30+
text=True,
31+
check=False,
32+
env=env,
33+
)
34+
35+
if result.returncode != 0:
36+
if result.stdout.strip():
37+
print(result.stdout.strip())
38+
if result.stderr.strip():
39+
print(result.stderr.strip())
40+
return result.returncode
41+
42+
43+
if __name__ == "__main__":
44+
raise SystemExit(main())

0 commit comments

Comments
 (0)