Repository navigation
fix(guard): check every refspec; add a harmless --self-check - #2
Merged
Merged
Conversation
Parse the command line as argv and check every refspec of every push in it, instead of only the first. Add --self-check, a read-only JSON receipt of the protected branches and hook registration state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PG-1 (narrowed) and PG-2 from the portfolio remediation plan, one commit because both units edit the same script and test file.
git pushas argv and checks every refspec of every push on the line. Before, only the first refspec after the remote was read, sogit push origin feat/x mainandgit push origin a && git push origin maingot through.&∧chains,git -C dir push, option values,--deleteacross all refspecs, the empty-source deletion refspec,+prefixes and a bareHEAD(now resolved to the current branch). On an unbalanced quote it falls back to a plain split and still checks the command.--self-checkprints a read-only JSON receipt: script SHA-256, effective protected branches and their source, the advisory/fail-open contract, and a registration status ofactive,registered-script-missing,registered-not-for-bash,not-registeredorno-settings(exit 0 only foractive). It runs no git, reads no stdin and never pushes.--all,--mirror, wildcard and tag refspecs, backtick substitution) and the self-check.Test plan
test_block_direct_integration_push.py; red first: 22 failed before the change.Acceptance
registration.statusand exit code; the check makes no remote call andremote_mutationis always false.