Repository navigation
Conversation
…ests Git exports GIT_DIR to hooks that run from a linked worktree, and pre-push runs test.sh. Tests that run git in a throwaway repo then commit to and configure the developer's repository instead. Unset GIT_DIR, GIT_WORK_TREE and GIT_INDEX_FILE before running pytest. Also assert that pre-commit and pre-push still fail on unformatted code. The repo fixture stubs `timeout`, which stock macOS lacks, so the pre-push assertion holds there for the same reason as on Linux. Follow-up to openenv#1576
This branch has not been deployed
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.
Summary
Follow-up to the #1576 review: finding 1 and the optional assertion in 2.
Git exports
GIT_DIRto hooks that run from a linked worktree, and pre-push runstest.sh. Tests that run git in a throwaway repo, such as therepofixture intests/scripts/test_lint_hook.py, then commit to and configure the developer's repository instead.test.shnow unsetsGIT_DIR,GIT_WORK_TREEandGIT_INDEX_FILEbefore it runs pytest.The hook test also asserts that pre-commit and pre-push still fail on unformatted code. The
repofixture stubstimeout, which stock macOS lacks, so on macOS the pre-push assertion holds for the same reason as on Linux.lint.shalready clearsGIT_DIRandGIT_WORK_TREEfor its owngit init(#1573).Type of Change
Alignment Checklist
.claude/docs/PRINCIPLES.mdand this PR aligns with our principles.claude/docs/INVARIANTS.mdand no invariants are violated/pre-submit-pr(orbash .claude/hooks/lint.shand tests) and addressed all issues.lint.shpasses, andtests/scripts/passes.RFC Status
Test Plan
test_test_hook_clears_git_hook_environmentrunstest.shwith the three variables set and a stubuvthat prints its environment. It fails onmain, where all three reach pytest, and passes here.test_git_hooks_leave_uncommitted_work_alonefails for both hooks when theirlint.shcall is removed.git pushfrom a linked worktree, with the hooks thatinstall.shwrites and a stubuvthat does what therepofixture does.main'stest.sh, the repository's config getscore.bare=true,core.hooksPath=/dev/nullanduser.email=t@example.com, afixture-initcommit is created, and the worktree's index is replaced. The push itself succeeds.test.shwithGIT_DIRset also passes all 14 tests intest_lint_hook.py. That run ignoredtests/envs/test_sql_optim_environment.py, which CI also ignores and which fails to collect withoutduckdb.Claude Code Review
/alignment-reviewchecks (lint.sh,check-debug.sh, PRINCIPLES, INVARIANTS, RFCs): no Tier 1 issues, no alignment flags.Note
Low Risk
Isolated change to the pre-push test hook plus hook regression tests; no production auth or data paths.
Overview
Pre-push
test.shnow unsetsGIT_DIR,GIT_WORK_TREE, andGIT_INDEX_FILEbefore invoking pytest so hook-injected git paths from linked worktrees do not leak into tests that create throwaway repos.Hook tests add a
timeoutstub for macOS, assert pre-commit/pre-push still exit non-zero when code needs formatting, and addtest_test_hook_clears_git_hook_environmentto verify those variables are not passed through to the test run.Reviewed by Cursor Bugbot for commit 94ea577. Bugbot is set up for automated code reviews on this repo. Configure here.