@@ -438,11 +438,22 @@ func TestRun_StampsImporterGitAuthorOnCheckpointCommit(t *testing.T) {
438438// same "Unknown"/"unknown@local" default checkpoint.GetGitAuthorFromRepo
439439// already applies elsewhere, rather than an empty one.
440440func TestRun_UnconfiguredGitIdentityFallsBackToDefaults (t * testing.T ) {
441- // Cannot use t.Parallel(): isolates HOME via t.Setenv so this repo's
442- // global git config resolution can't see the developer's real ~/.gitconfig.
441+ // Cannot use t.Parallel(): isolates git config resolution via t.Setenv so
442+ // this repo can't see any real identity. GetGitAuthorFromRepo resolves
443+ // GlobalScope through go-git's Auto loader, which reads all of git's global
444+ // sources; neutralize every one or the fallback assertion is flaky wherever
445+ // an identity is configured (~/.gitconfig, XDG, GIT_CONFIG_GLOBAL, or system
446+ // /etc/gitconfig). Mirrors the checkpoint package's pointHomeAt helper.
443447 home := t .TempDir ()
444448 t .Setenv ("HOME" , home )
445449 t .Setenv ("XDG_CONFIG_HOME" , "" )
450+ t .Setenv ("GIT_CONFIG_NOSYSTEM" , "1" )
451+ // t.Setenv registers restoration of the original value; unset it for the
452+ // test since an empty GIT_CONFIG_GLOBAL disables global config entirely.
453+ t .Setenv ("GIT_CONFIG_GLOBAL" , "" )
454+ if err := os .Unsetenv ("GIT_CONFIG_GLOBAL" ); err != nil {
455+ t .Fatal (err )
456+ }
446457
447458 repoDir := t .TempDir ()
448459 repo , err := git .PlainInit (repoDir , false )
0 commit comments