Skip to content

Commit 3070326

Browse files
committed
. e automatically clone DiffTools
1 parent 74b078d commit 3070326

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.ignore/
2+
13
.secrets
24
*.class
35
/webPageImages

.mise.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[tools]
22
maven = "latest"
3+
python = "latest"
34

45
[tasks]
56
build_and_test = "mvn --quiet -B verify --file pom.xml"

build/generate_diff_reporters.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
import csv
88
from collections import OrderedDict
99
from pathlib import Path
10+
import subprocess
1011

1112
SCRIPT_DIR = Path(__file__).parent
13+
14+
_DIFF_TOOLS_REPO_URL = "https://github.com/approvals/DiffTools"
15+
1216
PROJECT_ROOT = SCRIPT_DIR.parent
13-
CSV_PATH = PROJECT_ROOT / 'approvaltests' / 'DiffTools' / 'diff_reporters.csv'
17+
_DIFF_TOOLS_DIR = PROJECT_ROOT / '.ignore/DiffTools'
18+
CSV_PATH = _DIFF_TOOLS_DIR / 'diff_reporters.csv'
1419
BASE_OUTPUT = (PROJECT_ROOT / 'approvaltests' / 'src' / 'main' / 'java'
1520
/ 'org' / 'approvaltests' / 'reporters')
1621

@@ -232,6 +237,22 @@ def generate_os_aggregator(os_name, os_rows):
232237
lines.append('')
233238
write_java(BASE_OUTPUT / os_pkg / f'{cls}.java', '\n'.join(lines))
234239

240+
def clone_and_update_diff_tools() -> None:
241+
if not _DIFF_TOOLS_DIR.exists():
242+
subprocess.run(
243+
["git", "clone", _DIFF_TOOLS_REPO_URL, _DIFF_TOOLS_DIR.as_posix()],
244+
check=True,
245+
)
246+
return
247+
248+
if not _DIFF_TOOLS_DIR.joinpath(".git").exists():
249+
raise RuntimeError(f"{_DIFF_TOOLS_DIR} exists but is not a git repository")
250+
251+
subprocess.run(
252+
["git", "-C", _DIFF_TOOLS_DIR.as_posix(), "pull", "--ff-only"],
253+
check=True,
254+
)
255+
235256

236257
# ---------------------------------------------------------------------------
237258
# Main
@@ -241,6 +262,8 @@ def main():
241262
print('Generating diff reporter classes from diff_reporters.csv...')
242263
print()
243264

265+
clone_and_update_diff_tools()
266+
244267
with open(CSV_PATH, newline='', encoding='utf-8') as f:
245268
rows = list(csv.DictReader(f))
246269

0 commit comments

Comments
 (0)