test: isolate git config in attach tests to fix TempDir cleanup flake · Entire
test: isolate git config in attach tests to fix TempDir cleanup flake
33cb6db→main·
Soph·1mo ago·1 file·+5 added/-0 removed
TestAttachCmd_* / TestReviewAttach_* intermittently failed in t.TempDir cleanup, not on an assertion:
TempDir RemoveAll cleanup: unlinkat .../001/.git/objects: directory not empty
Root cause (COR-394): attach runs git commit --amend via the git CLI (attach.go), which inherits the process env and the developer's real git config. With default gc.auto/gc.autoDetach, the commit forks a detached git gc that keeps writing into the temp repo's .git/objects after rootCmd.Execute() returns, racing Go's deferred os.RemoveAll.
setupAttachTestRepo set up repo-local identity (testutil.InitRepo) but never isolated global/system git config, so the gc-disabling pins didn't apply. Add testutil.IsolateGitConfigEnv(t) — it sets GIT_CONFIG_GLOBAL/SYSTEM to the isolation config (gc.auto=0, gc.autoDetach=false, maintenance.auto=false), the central remedy for exactly this race. Compatible with the helper's existing t.Chdir (both non-parallel).
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Sessions
9a948bc09627View transcript
[?
so in ../entiredb "filtered_fetches" is enabled, now today one of my coworkers had this issue:Claude Code·5 steps](/content/gh/entireio/cli/session/e1c2cd64-bc7d-4315-9abd-f106c4eaa991#timeline-9a948bc09627/index.html)
Changes
1
cmd/entire/cli
Mattach_test.go+5
1500 unmodified lines
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1500 unmodified lines
t.Helper()
tmpDir := t.TempDir()
testutil.InitRepo(t, tmpDir)
// attach runs `git commit --amend` via the git CLI, which inherits this
// process's env. Pin git config (gc.auto=0, gc.autoDetach=false) so git
// doesn't fork a detached `git gc` that keeps writing into the temp repo's
// .git/objects and races t.TempDir cleanup ("directory not empty", COR-394).
testutil.IsolateGitConfigEnv(t)
testutil.WriteFile(t, tmpDir, "init.txt", "init")
testutil.GitAdd(t, tmpDir, "init.txt")
testutil.GitCommit(t, tmpDir, "init")
Mcmd/entire/cli/attach_test.go+5