Skip to content

fix(hooks): detect git branch force-delete flag variants - #299

Open
atomicdjt wants to merge 2 commits into
griddynamics:mainfrom
atomicdjt:fix/git-branch-force-delete-296
Open

fix(hooks): detect git branch force-delete flag variants#299
atomicdjt wants to merge 2 commits into
griddynamics:mainfrom
atomicdjt:fix/git-branch-force-delete-296

Conversation

@atomicdjt

Copy link
Copy Markdown

Closes #296

Why

The git-branch-delete guard only recognized literal git branch -D, even though Git accepts equivalent force-delete forms such as -d -f, -fd, -df, and --delete --force.

Those variants could bypass the existing reconsider safety guard.

What changed

  • split git branch force-delete detection into independent delete + force checks
  • support short, long, separate, mixed, and reordered flag forms
  • preserve ordinary non-force git branch -d / --delete behavior
  • bound detection at common shell command separators so a later command cannot supply the missing force/delete flag
  • add focused regression coverage for:
    • force-delete variants
    • evaluateDangerous() deny behavior
    • # Rosetta-AI-reviewed override behavior
    • safe non-force commands
    • cross-command false positives

Scope

Two files only:

  • src/hooks/src/hooks/dangerous-actions/patterns.ts
  • src/hooks/tests/git-branch-delete.test.ts

No unrelated refactor or guardrail-policy changes.

Validation

  • isolated executable detector matrix: 20/20 passed
  • based on current upstream main at fca6be111aec87c55c877047184f723d671d3598
  • both commits include DCO Signed-off-by trailers

The full repository dependency/test suite could not be executed from the ChatGPT tool environment because that runtime cannot fetch the repository's npm dependencies. The change was instead kept narrowly scoped and validated against the relevant behavior directly.

Risk / behavior boundary

This only broadens the existing git-branch-delete reconsider guard to equivalent force-delete syntax.

It does not introduce a hard-deny path, and normal non-force branch deletion remains unguarded as before.

AI assistance was used to implement and review this change. I reviewed and take responsibility for the submitted diff, consistent with the repository's AI-assisted contribution policy.

Signed-off-by: David Turner <davidelsey9513@gmail.com>
Signed-off-by: David Turner <davidelsey9513@gmail.com>
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.

[ROSETTA] dangerous-actions git-branch-delete pattern misses force-delete flag variants

1 participant