Block git push --prune in the pre-bash guard#40
Merged
Conversation
Summary Extend the push guard to catch `git push --prune`, which deletes remote refs that have no local counterpart — remote-destructive. Follow-up to the `+<refspec>` (#38) and `--mirror` (#39) guards. - add a dedicated `_GUARD_GIT_PUSH_PRUNE` guard and a `--prune)` arm, with its own message - bare `--all` is intentionally NOT guarded: it only pushes branches and is destructive only combined with `--force`, which is already caught Testing - new `agent-hook-bash-guards-test` cases: `git push --prune ...` is blocked with the prune-specific message; bare `git push --all origin` stays allowed - verified red-green: removing the `--prune)` arm lets `--prune` through (exit 0) - full suite green (`./test/agentguard-test`: all suites 0 failed); `checkrun lint` clean
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
Extend the push guard to catch
git push --prune, which deletes remoterefs that have no local counterpart — remote-destructive. Follow-up to
the
+<refspec>(#38) and--mirror(#39) guards._GUARD_GIT_PUSH_PRUNEguard and a--prune)arm, withits own message
--allis intentionally NOT guarded: it only pushes branches andis destructive only combined with
--force, which is already caughtTesting
agent-hook-bash-guards-testcases:git push --prune ...isblocked with the prune-specific message; bare
git push --all originstays allowed
--prune)arm lets--prunethrough(exit 0)
./test/agentguard-test: all suites 0 failed);checkrun lintclean