Repository navigation
fix(hooks): run pre-commit checks without git's GIT_DIR/GIT_INDEX_FILE - #15
Merged
Merged
Conversation
Git exports GIT_DIR and GIT_INDEX_FILE to hooks. test_tool_dispatcher's fixture runs git init/config in a tmp dir, which then wrote to the real repo config (core.bare=true and a fake user identity). Unset the git variables before running black and pytest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Git exports
GIT_DIRandGIT_INDEX_FILEto hooks.tests/test_tool_dispatcher.pyrunsgit init/git configin a tmp dir, so a commit that triggered the pre-commit hook (seen from a worktree) wrote into the real repo config:core.bare=trueand a fakeuser.name=Test/user.email=test@test.com.Fix: unset the git variables in
.githooks/pre-commitbefore running black and pytest.Verified: committed a backend test file through the hook from a worktree. Hook ran black + the full suite (3385 passed), and
.git/configwas byte-identical before and after.🤖 Generated with Claude Code