From 6666850871091a8caa0d24b7c84247568a3a4277 Mon Sep 17 00:00:00 2001 From: Kynan Ware <47394200+BagToad@users.noreply.github.com> Date: Wed, 25 Mar 2026 12:05:20 -0600 Subject: [PATCH] fix(acceptance): set git identity in testscript sandbox The sandbox overrides HOME so git cannot find the user's global config, causing 'Author identity unknown' errors when acceptance test scripts make commits. Write a minimal .gitconfig with user.name and user.email into the sandbox working directory during sharedSetup. Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com> --- acceptance/acceptance_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index b8eff8389..98642afaf 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "path" + "path/filepath" "strconv" "strings" "testing" @@ -15,6 +16,7 @@ import ( "github.com/cli/cli/v2/internal/ghcmd" "github.com/cli/go-internal/testscript" + "github.com/MakeNowJust/heredoc" ) func ghMain() int { @@ -224,6 +226,19 @@ func sharedSetup(tsEnv testScriptEnv) func(ts *testscript.Env) error { ts.Setenv("RANDOM_STRING", randomString(10)) + // The sandbox overrides HOME, so git cannot find the user's global + // config. Write a minimal identity so commits inside the sandbox + // don't fail with "Author identity unknown". + gitCfg := filepath.Join(ts.Cd, ".gitconfig") + gitCfgContent := heredoc.Doc(` + [user] + name = GitHub CLI Acceptance Test Runner + email = cli-acceptance-test-runner@github.com + `) + if err := os.WriteFile(gitCfg, []byte(gitCfgContent), 0o644); err != nil { + return fmt.Errorf("writing sandbox .gitconfig: %w", err) + } + ts.Values[keyT] = ts.T() return nil }