Skip to content

fix: narrow git push hook regex to avoid substring false positives#47

Open
hbrodin wants to merge 2 commits intomainfrom
fix/push-hook-substring-match
Open

fix: narrow git push hook regex to avoid substring false positives#47
hbrodin wants to merge 2 commits intomainfrom
fix/push-hook-substring-match

Conversation

@hbrodin
Copy link
Copy Markdown

@hbrodin hbrodin commented Apr 2, 2026

Fixes #46

The regex git[[:space:]]+push.*(main|master) matches "main" anywhere in the command, false-positiving on branches like deps/aiohttp-3.13.5-remaining or feature/maintain-state.

Requires main/master to be preceded by whitespace, :, /, or + and followed by whitespace or end-of-string — covering direct pushes, refspecs, fully-qualified refs, and force prefixes while allowing branch names containing these as substrings.

🤖 Generated with Claude Code

hbrodin and others added 2 commits April 2, 2026 11:17
Fixes #46

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use [[:space:]:/+] instead of alternation group with \+ —
unambiguously literal in all POSIX ERE implementations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.

git push hook regex false-positives on branch names containing "main"

1 participant