Skip to content

Block git push --prune in the pre-bash guard#40

Merged
cgraf78 merged 1 commit into
mainfrom
fix-push-prune-guard
Jul 2, 2026
Merged

Block git push --prune in the pre-bash guard#40
cgraf78 merged 1 commit into
mainfrom
fix-push-prune-guard

Conversation

@cgraf78

@cgraf78 cgraf78 commented Jul 2, 2026

Copy link
Copy Markdown
Owner

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

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
@cgraf78 cgraf78 merged commit 84b593c into main Jul 2, 2026
6 checks passed
@cgraf78 cgraf78 deleted the fix-push-prune-guard branch July 2, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant