Skip to content

test(import): fully isolate git config in author fallback test#1849

Merged
gtrrz-victor merged 1 commit into
mainfrom
fix/import-author-test-isolation
Jul 24, 2026
Merged

test(import): fully isolate git config in author fallback test#1849
gtrrz-victor merged 1 commit into
mainfrom
fix/import-author-test-isolation

Conversation

@gtrrz-victor

@gtrrz-victor gtrrz-victor commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/935

Stacked on #1846.

Summary

Copilot flagged that TestRun_UnconfiguredGitIdentityFallsBackToDefaults (added in #1846) only overrides HOME/XDG_CONFIG_HOME. But checkpoint.GetGitAuthorFromRepo resolves GlobalScope through go-git's Auto loader, which also honors GIT_CONFIG_GLOBAL and the system /etc/gitconfig. On any dev machine or CI image where either carries a git identity (e.g. GIT_CONFIG_GLOBAL set by chezmoi/direnv — the same dotfile-tool setups configloader.go exists to handle), the Unknown/unknown@local assertion would flake.

The fix neutralizes every global source, matching the checkpoint package's own pointHomeAt helper (checkpoint/configloader_test.go:52, checkpoint/global_test.go:39):

  • GIT_CONFIG_NOSYSTEM=1 — skip /etc/gitconfig
  • unset GIT_CONFIG_GLOBAL — fall back to XDG (empty value would disable global config entirely, so it is unset, not emptied)

Production code is unchanged; this is test-isolation hardening only. The sibling TestRun_StampsImporterGitAuthorOnCheckpointCommit was never at risk — it uses repo-local identity, which wins go-git's config merge regardless of global/system.

Test plan

  • go test ./cmd/entire/cli/agentimport/ -run 'TestRun_Unconfigured...|TestRun_Stamps...' -count=1 green
  • golangci-lint (v2.11.3) 0 issues

🤖 Generated with Claude Code


Note

Low Risk
Test-only comment and environment setup; no runtime behavior changes.

Overview
Hardens TestRun_UnconfiguredGitIdentityFallsBackToDefaults so it no longer flakes when the host has git identity outside HOME/XDG_CONFIG_HOME.

The test now sets GIT_CONFIG_NOSYSTEM=1 and unsets GIT_CONFIG_GLOBAL (after t.Setenv for cleanup), matching the checkpoint package’s pointHomeAt helper. That blocks go-git’s global config sources (/etc/gitconfig, GIT_CONFIG_GLOBAL, etc.) so Unknown / unknown@local assertions stay reliable. Comments were expanded to document why full isolation is required.

No production code changes — test isolation only.

Reviewed by Cursor Bugbot for commit 3dda7ee. Configure here.

TestRun_UnconfiguredGitIdentityFallsBackToDefaults overrode only HOME and
XDG_CONFIG_HOME, but GetGitAuthorFromRepo resolves GlobalScope through
go-git's Auto loader, which also honors GIT_CONFIG_GLOBAL and system
/etc/gitconfig. On any machine/CI where one of those carries a git identity
the "Unknown"/"unknown@local" assertion would flake.

Neutralize every global source the way the checkpoint package's pointHomeAt
helper already does: set GIT_CONFIG_NOSYSTEM=1 and unset GIT_CONFIG_GLOBAL.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 01KY9MM18RHEBYFH4Y4QVJK7RT
Copilot AI review requested due to automatic review settings July 24, 2026 08:42
@gtrrz-victor
gtrrz-victor requested a review from a team as a code owner July 24, 2026 08:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens entire import’s author-fallback unit test so it’s fully isolated from any host/global Git identity configuration, preventing flakes caused by go-git’s global config resolution behavior.

Changes:

  • Expanded the test comment to document why additional git config isolation is required.
  • In TestRun_UnconfiguredGitIdentityFallsBackToDefaults, set GIT_CONFIG_NOSYSTEM=1 and explicitly unset GIT_CONFIG_GLOBAL (while still restoring it after the test via t.Setenv).

Base automatically changed from feat/import-author-signature to main July 24, 2026 08:48
@gtrrz-victor
gtrrz-victor merged commit 69d2ec5 into main Jul 24, 2026
12 checks passed
@gtrrz-victor
gtrrz-victor deleted the fix/import-author-test-isolation branch July 24, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants