mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-06 01:53:56 -06:00
fix: refuse numbered review tags in commits
A subject that points at a numbered private review names notes no clone holds, and pushed history cannot be rewritten. The hook now refuses those tags like the tracked-file test does.
This commit is contained in:
1 parent
c624a820f0
commit
fefc9ca16f
2 files changed
+27
No files matched your search
@@ -21,6 +21,14 @@ REFUSED_WORDS = re.compile(
|
||||
r"comprehensive|implement)",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
# A numbered pointer at a private review ("audit 24", "review 3", "round 5")
|
||||
# names notes no clone holds. tests/test_prose_style.py refuses the same tags
|
||||
# in tracked files, and history cannot be rewritten once pushed.
|
||||
REVIEW_TAG = re.compile(
|
||||
r"\b(audit|review|round|batch|finding)s? #?\d+|\baudit (batch|findings?)\b"
|
||||
r"|[a-z]+_audit_\d+",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
CO_AUTHOR = re.compile(r"^co-authored-by", re.IGNORECASE | re.MULTILINE)
|
||||
|
||||
|
||||
@@ -35,6 +43,8 @@ def problems(message: str) -> list[str]:
|
||||
text = "\n".join(line for line in message.splitlines() if not line.startswith("#"))
|
||||
if REFUSED_WORDS.search(text):
|
||||
found.append("the message uses a word this repository's history does not carry")
|
||||
if REVIEW_TAG.search(text):
|
||||
found.append("say what the change does, not which review asked for it")
|
||||
if CO_AUTHOR.search(message):
|
||||
found.append("no Co-Authored-By trailer here")
|
||||
return found
|
||||
|
||||
@@ -955,6 +955,23 @@ class SubjectsFollowTheRepositoryRules(unittest.TestCase):
|
||||
self.assertTrue(ar.check_subject(subject))
|
||||
self.assertEqual(ar.check_subject("chore: tidy the cache"), [])
|
||||
|
||||
def test_review_numbers_are_refused(self):
|
||||
"""47 pushed subjects pointed at a numbered private review, which no
|
||||
clone can follow. The subject says what the change does."""
|
||||
import commit_rules # noqa: PLC0415
|
||||
|
||||
for subject in ("chore: audit 24 and 17 cases, host kept out",
|
||||
"fix: polish the screens audit 11 named",
|
||||
"chore: merge audit batch, resolver and profiles",
|
||||
"fix: settle the review 3 notes"):
|
||||
with self.subTest(subject=subject):
|
||||
self.assertTrue(commit_rules.problems(subject))
|
||||
for subject in ("fix: scroll long messages in the installer",
|
||||
"feat: read regions in region_audit.py",
|
||||
"chore: merge resolver and profile fixes"):
|
||||
with self.subTest(subject=subject):
|
||||
self.assertEqual(commit_rules.problems(subject), [])
|
||||
|
||||
def test_the_rules_run_as_a_hook(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
message = Path(tmp) / "MSG"
|
||||
|
||||
Reference in new issue
Block a user