in common.go:296 we are initializing the shadow branch with "entire@local" could we…
- User
in common.go:296 we are initializing the shadow branch with "entire@local" could we change this to use the current git user in the same way we do this on shadow branches and also following commits to the entire/checkpoints/v1 branch?
Assistant
Let me look at the relevant code to understand the current implementation and how the git user is resolved elsewhere.
Assistant
Let me see the
GetGitAuthorFromRepofunction to understand the existing pattern.Assistant
Now let me see the function signature around line 296 to understand what
repois available.Assistant
The function
EnsureMetadataBranchalready has access torepo *git.Repository, andGetGitAuthorFromRepotakes the same parameter. This is a straightforward change.Assistant
Now let me verify the build passes.
Assistant
Done. The change at
common.go:294now callsGetGitAuthorFromRepo(repo)instead of hardcoding"Entire"/"entire@local". This uses the same function already used for shadow branch andentire/checkpoints/v1commits, which checks local git config first, then global config, and falls back to"Unknown"/"unknown@local"if neither is configured.- User
what kind of fallbacks does GetGitAuthorFromRepo have?
Assistant
From
common.go:1418-1448, it has a three-tier fallback:- Local repo config — reads
user.nameanduser.emailfrom the repository's.git/config - Global git config — if either is still empty, reads from
~/.gitconfig - Hardcoded defaults — if still empty:
"Unknown"for name,"unknown@local"for email
- Local repo config — reads
- User
does the method has tests so far?
Assistant
No,
GetGitAuthorFromRepohas no tests currently.- User
can you validate first what the default behavior from the git cli is if only one (name or email) is defined local? is the other then taken from global?
Assistant
Let me test this empirically.
Assistant
Yes — git CLI does the same thing: when only
user.nameis set locally, it takesuser.emailfrom global config. Each field is resolved independently through the config cascade (local → global → system).GetGitAuthorFromRepoalready matches this behavior — it checks each field separately and falls back to global for whichever one is missing.- User
ok, then add some tests for this behavior
Assistant
Let me check existing test patterns in the strategy package for setting up git repos in tests.
Assistant
Let me look at how config is set in tests, particularly the
phase_wiring_test.goexample that setscfg.User.Assistant
Now let me see the end of
common_test.goto know where to append the new test.Assistant
Now I need to understand how go-git handles global config in tests. Let me check if there's a way to set it via the repo config or if we need the
configpackage.Assistant
The global config fallback reads from
~/.gitconfig. In tests we can't easily control that without writing to the filesystem. Let me check the import for config.Assistant
Now let me check what imports
common_test.gouses and also check howgo-gitconfig scope works — specifically, can we set both local name and email to empty to test the global fallback path, or do we need to useXDG_CONFIG_HOME/HOMEto isolate global config?Assistant
Good —
common_test.gouses plaint.Fatalf/t.Errorfstyle (no testify). Now let me also check ifXDG_CONFIG_HOMEis relevant for go-git's global config resolution, since go-git might look there too.Assistant
Good — go-git checks
XDG_CONFIG_HOME, then$HOME/.gitconfig, then$HOME/.config/git/config. SettingHOMEto a temp dir will isolate global config. I also need to unsetXDG_CONFIG_HOMEto avoid picking up the real config.Assistant
All 6 tests pass:
- Both set locally — returns local values
- Only name local — falls back to global for email
- Only email local — falls back to global for name
- Nothing local, both global — returns global values
- Nothing anywhere — returns defaults (
"Unknown","unknown@local") - Local takes precedence — local overrides global when both are set