Skip to content

fix: git -C strip + skip merged check on checkout chains#33

Merged
George-iam merged 1 commit intomainfrom
fix/git-c-flag-and-checkout-skip-20260407
Apr 7, 2026
Merged

fix: git -C strip + skip merged check on checkout chains#33
George-iam merged 1 commit intomainfrom
fix/git-c-flag-and-checkout-skip-20260407

Conversation

@George-iam
Copy link
Copy Markdown
Contributor

Summary

  1. Strip git -C <path> prefix in checkGit before startsWith checks. git -C repo commit now correctly matches git commit pattern.
  2. Skip merged-PR check when command chain includes git checkout/git switch. Hook runs BEFORE execution, so current branch is stale when checkout is in the chain.

Root cause

  • git -C axme-code commit was not blocked because startsWith("git commit") failed
  • git stash && git checkout main && git commit was blocked because hook checked current (pre-checkout) branch

…kout

Two fixes for safety hook:
1. Strip -C <path> from git commands before startsWith checks so
   "git -C repo commit" matches "git commit" pattern.
2. Skip merged-PR check when command chain includes git checkout/switch,
   because hook runs BEFORE execution and branch will change.
@George-iam George-iam merged commit 4802d10 into main Apr 7, 2026
@George-iam George-iam deleted the fix/git-c-flag-and-checkout-skip-20260407 branch April 7, 2026 15:26
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