Skip to content

Commit

Permalink
Little improvement to the workflow generator (pantsbuild#19893)
Browse files Browse the repository at this point in the history
This change prints a diff, and also suggests merging with latest `main`,
and was also crafted from my tears...
  • Loading branch information
thejcannon authored Sep 21, 2023
1 parent 2546387 commit c3acd9d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/python/pants_release/generate_github_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

import argparse
import difflib
import os
import re
from dataclasses import dataclass, field
Expand Down Expand Up @@ -1736,14 +1737,24 @@ def main() -> None:
args = create_parser().parse_args()
generated_yaml = generate()
if args.check:
for path, content in generated_yaml.items():
if path.read_text() != content:
for path, expected in generated_yaml.items():
actual = path.read_text()
if actual != expected:
diff = difflib.unified_diff(
actual.splitlines(),
expected.splitlines(),
fromfile="actual",
tofile="expected",
lineterm="",
)
die(
os.linesep.join(
(
f"Error: Generated path mismatched: {path}",
"To re-generate, run: `./pants run src/python/pants_release/"
"generate_github_workflows.py`",
"To re-generate, run: `./pants run src/python/pants_release/generate_github_workflows.py`",
"Also note that you might need to merge the latest changes to `main` to this branch.",
"Diff:",
*diff,
)
)
)
Expand Down

0 comments on commit c3acd9d

Please sign in to comment.