From f7b448ccbf1a3b523845abcb9f10d59dc92b303f Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 18:13:46 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20principles=20round=203:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=201=20=F0=9F=9F=A1=20(0=20misread);=20offer=20--a?= =?UTF-8?q?mend=20only=20where=20the=20round=20commit=20is=20the=20newest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/rule_hook/round_cap.py | 5 +++-- bin/rule_hook/test_rule_hook.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/rule_hook/round_cap.py b/bin/rule_hook/round_cap.py index ad6f1c36..a849aa23 100644 --- a/bin/rule_hook/round_cap.py +++ b/bin/rule_hook/round_cap.py @@ -10,14 +10,15 @@ def round_cap_breaches(commit: Commit) -> list[Breach]: if not any(ROUND.match(message) for message in commit.messages): return [] earlier = earlier_titles(commit.directory, commit.amends) - return [Breach("round-cap", refusal(named.group(1).lower(), message, earlier), commit.directory) for message in commit.messages if (named := ROUND.match(message)) and past_cap(message, earlier)] + refused = [(named.group(1).lower(), message) for message in commit.messages if (named := ROUND.match(message)) and past_cap(message, earlier)] + return [Breach("round-cap", refusal(name, message, earlier), commit.directory) for name, message in refused] def refusal(name: str, title: str, earlier: list[str]) -> str: """Why title, a round title of the pass name, is refused, listing the pass's round commits counted, and how to commit the fixes in hand.""" counted = [earlier_title for earlier_title in earlier if (named := ROUND.match(earlier_title)) and named.group(1).lower() == name] listed = ", ".join(f"`{counted_title}`" for counted_title in counted) or "none" - return f"this would be {name}'s round {round_counts([*counted, title])[name]}, past its {CAP}; {name}'s round commits on this branch: {listed}. Fold the fixes into its last round commit with `git commit --amend`, or commit them under a title that doesn't open `Answer round`; they merge once the gate passes" + return f"this would be {name}'s round {round_counts([*counted, title])[name]}, past its {CAP}; {name}'s round commits on this branch: {listed}. Fold the fixes into its last round commit with `git commit --amend` where that is the newest commit, or commit them under a title that doesn't open `Answer round`; they merge once the gate passes" def earlier_titles(directory: str, amends: bool) -> list[str]: diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index 03678826..009e0800 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -672,7 +672,7 @@ class Hook(unittest.TestCase): ran = self.round_commit("Answer stability round 2: 0 🔴, 0 🟡 (0 misread); d") self.assertEqual(ran.returncode, 2) self.assertIn("stability's round commits on this branch: `Answer stability round 2: 0 🔴, 1 🟡 (0 misread); c`, `Answer stability round 1: 1 🔴, 0 🟡 (0 misread); a`", ran.stderr) - self.assertIn("`git commit --amend`", ran.stderr) + self.assertIn("`git commit --amend` where that is the newest commit", ran.stderr) self.assertEqual(self.round_commit("Answer prose round 2: 0 🔴, 0 🟡 (0 misread); d").returncode, 0) self.assertEqual(self.round_commit("Answer stability round 2: 0 🔴, 1 🟡 (0 misread); c, reworded", "--amend --allow-empty ").returncode, 0, "an amend replaces the commit it counts") git(self.repo, "commit", "-q", "--allow-empty", "-m", "fix a typo")