Answer stability round 1: 0 🔴, 3 🟡 (0 misread); pin the guarded default-branch reads and which commit an amend drops, and name the pass and its counted commits in the refusal
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from rule_hook.rules import Breach
|
||||
from round_titles import CAP, past_cap, ROUND
|
||||
from round_titles import CAP, past_cap, ROUND, round_counts
|
||||
from git_command import Commit
|
||||
from failure import Failure
|
||||
import git_repo
|
||||
@@ -10,13 +10,18 @@ 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)
|
||||
if not any(past_cap(message, earlier) for message in commit.messages):
|
||||
return []
|
||||
return [Breach("round-cap", f"the pass has had its {CAP} rounds; merge once the gate passes, with no round after them", commit.directory)]
|
||||
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)]
|
||||
|
||||
|
||||
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 <pass> round`; they merge once the gate passes"
|
||||
|
||||
|
||||
def earlier_titles(directory: str, amends: bool) -> list[str]:
|
||||
"""The branch's titles, less the one an --amend replaces; none where git cannot tell in time, so the title's own number still counts.
|
||||
"""The branch's titles, less the one an --amend replaces; none where git cannot list them within 5 seconds or the checkout records no default branch for origin, so the title's own number still counts.
|
||||
|
||||
Run guarded, as the hook runs git, which neither fetches nor asks origin: the default branch is as last fetched."""
|
||||
default = git_repo.default_ref(directory, guarded=True)
|
||||
|
||||
Reference in New Issue
Block a user