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)
| 10 | // |
| 11 | // https://git-scm.com/docs/git-config#ENVIRONMENT |
| 12 | func 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 | } |