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>
This commit is contained in:
parent
8f7d20855e
commit
6666850871
1 changed files with 15 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue