Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions scripts/repo_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ def check_sha_pin(root: Path, files: list[str]) -> list[str]:
unread += 1
else:
resolved += 1
if resolved or foreign or unowned or unread:
# One fixed shape every run, so a zero in any position is as visible as a count.
NOTES.append(f'resolved {resolved} pin(s) against GitHub. Read for shape only: '
f'{foreign} under another owner, {unowned} whose owner could not be '
f"compared because this checkout's origin is unreadable, "
f'{unread} GitHub did not answer for.')
# Unconditional, so an all-zero run is as visible as a count rather than a clean line.
# A guard on a non-zero counter hides the run that resolved nothing, which is this one.
NOTES.append(f'resolved {resolved} pin(s) against GitHub. Read for shape only: '
f'{foreign} under another owner, {unowned} whose owner could not be '
f"compared because this checkout's origin is unreadable, "
f'{unread} GitHub did not answer for.')
return bad


Expand Down
14 changes: 14 additions & 0 deletions scripts/test_repo_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,20 @@ def test_the_note_carries_every_count_including_the_zeroes(self) -> None:
with self.subTest(fragment=fragment):
self.assertIn(fragment, repo_gate.NOTES[0])

def test_the_note_prints_where_every_count_is_zero(self) -> None:
"""The all-zero run is the one the note exists for, and it was the one it skipped.

Guarded on a non-zero counter, the note went silent on a repository carrying no workflow
at all, which is exactly the clean line the docstring says nobody should have to infer
the check's narrowness from.
"""
repo_gate.check_sha_pin(self.tmp, [])
self.assertEqual(1, len(repo_gate.NOTES))
for fragment in ('resolved 0 pin(s)', '0 under another owner',
'0 whose owner could not be compared', '0 GitHub did not answer for'):
with self.subTest(fragment=fragment):
self.assertIn(fragment, repo_gate.NOTES[0])

def test_a_pin_github_did_not_answer_for_is_skipped_rather_than_failed(self) -> None:
"""Offline, unauthenticated and rate-limited all read as nothing learned, not as absent."""
self.answers({f'repos/{self.OWNER}/Fleet/commits/{PINNED}': None})
Expand Down