Skip to content

fix(husky): stop the pre-commit hook blocking every commit - #6

Merged
tkgstrator merged 3 commits into
masterfrom
fix/pre-commit-without-tests
Sep 4, 2026
Merged

fix(husky): stop the pre-commit hook blocking every commit#6
tkgstrator merged 3 commits into
masterfrom
fix/pre-commit-without-tests

Conversation

@tkgstrator

Copy link
Copy Markdown
Contributor

Summary

.husky/pre-commit runs bun test unconditionally. bun test exits 1 when it matches no test files, and this repo has none, so every commit is rejected:

error: 0 test files matching **{.test,.spec,_test_,_spec_}.{js,ts,jsx,tsx}
husky - pre-commit script failed (code 1)

Guarded on a test file actually existing:

if git ls-files | grep -qE '\.(test|spec)\.(js|jsx|ts|tsx)$'; then
  bun test
fi

This is not || true — a real test failure still blocks the commit. The step is skipped only while the repo has nothing to run, and the first test file added turns it back on by itself.

Note

Committed with --no-verify, because the hook being fixed is exactly what rejects the fix. Nothing else in the commit.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DLik2h14rdD7Ks6v5CHRGv

`bun test` exits 1 when it matches no test files, and this repo has none,
so the pre-commit hook fails on every commit:

    error: 0 test files matching **{.test,.spec,_test_,_spec_}.{js,ts,jsx,tsx}
    husky - pre-commit script failed (code 1)

Guarded on a test file actually existing. The first one added turns the
step back on by itself, so this does not quietly disable testing.

Committed with --no-verify because the hook being fixed is what rejects
the fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLik2h14rdD7Ks6v5CHRGv
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Failed to generate code suggestions for PR

tkgstrator and others added 2 commits September 4, 2026 02:34
The CI Test job runs the same bare `bun test`, so it fails for the same
reason the pre-commit hook did. Same guard, same reasoning: skip only
while there is nothing to run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLik2h14rdD7Ks6v5CHRGv
GitHub removed the ubuntu-20.04 hosted image, so the Validation job never
gets a runner: it sits QUEUED forever behind a check that can neither pass
nor fail. Every other job here is already on ubuntu-24.04.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLik2h14rdD7Ks6v5CHRGv
@tkgstrator
tkgstrator merged commit fba5ab1 into master Sep 4, 2026
7 checks passed
@tkgstrator
tkgstrator deleted the fix/pre-commit-without-tests branch September 4, 2026 02:38
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