MCPcopy Create free account
hub / github.com/cli/cli / IsolateConfig

Function IsolateConfig

git/test.go:12–25  ·  view source on GitHub ↗

IsolateConfig prevents the ambient git configuration from reaching tests that shell out to real git. https://git-scm.com/docs/git-config#ENVIRONMENT

(t *testing.T)

Source from the content-addressed store, hash-verified

10//
11// https://git-scm.com/docs/git-config#ENVIRONMENT
12func IsolateConfig(t *testing.T) {
13 t.Helper()
14
15 // Point the global config at an empty file and ignore the system one.
16 t.Setenv("GIT_CONFIG_GLOBAL", filepath.Join(t.TempDir(), ".gitconfig"))
17 t.Setenv("GIT_CONFIG_NOSYSTEM", "true")
18
19 // Config from these vars is command line scope, which outranks the global and
20 // system files, so redirecting those files alone leaves it in place. Tools that
21 // wrap git inject config this way, and an inherited safe.bareRepository=explicit
22 // makes git refuse to open a bare repository at all.
23 t.Setenv("GIT_CONFIG_COUNT", "")
24 t.Setenv("GIT_CONFIG_PARAMETERS", "")
25}

Calls 2

JoinMethod · 0.80
HelperMethod · 0.65