Skip to content

fix(hooks): skip pre-push checks for tag-only pushes - #78

Merged
jamesaphoenix merged 1 commit into
mainfrom
fix/pre-push-skip-tag-only
Aug 13, 2026
Merged

fix(hooks): skip pre-push checks for tag-only pushes#78
jamesaphoenix merged 1 commit into
mainfrom
fix/pre-push-skip-tag-only

Conversation

@jamesaphoenix

Copy link
Copy Markdown
Owner

Problem

.husky/pre-push ran scripts/check.sh --all unconditionally, without looking at what was being pushed. A release tag carries no new code: the commit it points at was already checked by this same hook when its branch was pushed, and again by CI. Re-running build + the full integration suite there can never produce a different answer.

Concretely, during the v0.18.0 release, git push origin v0.18.0 spent 5m20s re-running the suite and read as a hang.

Fix

The hook now reads the ref lines git sends on stdin (<local-ref> <local-oid> <remote-ref> <remote-oid>) and exits early only when every ref is a tag.

It deliberately fails safe: a push carrying any branch ref, a mixed branch-and-tag push, or stdin it cannot classify (empty/unexpected) runs the checks exactly as before. No code path reaches the remote unchecked.

Tests

Seven cases in test/integration/hooks.test.ts run the real .husky/pre-push against a stubbed scripts/check.sh that touches a marker file instead of executing the real suite. That keeps the test honest (it exercises the actual shipped hook, not a copy of its logic) while ensuring a regression in the guard fails in milliseconds rather than starting a multi-minute check run inside the test suite.

Covered: single tag, multiple tags, tag deletion, branch push, mixed branch+tag, empty stdin, and that a failing check.sh still blocks a branch push with exit 1.

.husky/pre-push ran scripts/check.sh --all unconditionally, with no
inspection of what was being pushed. Pushing a release tag therefore
re-ran the full build and integration suite against a commit that had
already passed the same hook when its branch was pushed, and passed CI
on top of that. During v0.18.0 this added 5m20s to the release and
looked like a hang.

The hook now reads the ref lines git sends on stdin and exits early only
when every ref is a tag. Anything else, including a mixed branch-and-tag
push or input it cannot classify, runs the checks exactly as before, so
no code can reach the remote unchecked.

Tests run the real hook against a stubbed check.sh that records whether
it was invoked, so a regression in the guard fails in milliseconds
instead of starting a real multi-minute check run inside the suite.
@jamesaphoenix
jamesaphoenix merged commit 33e234a into main Aug 13, 2026
2 checks passed
@jamesaphoenix
jamesaphoenix deleted the fix/pre-push-skip-tag-only branch August 13, 2026 21:57
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