mirror of
https://github.com/tailscale/tailscale.git
synced 2026-10-23 03:37:19 +09:00
version/mkversion: don't use os.DevNull for git config in tests
Git for Windows 2.56.0 rejects GIT_CONFIG_GLOBAL=NUL with "unable to access 'NUL': Invalid argument" (git-for-windows/git#6449), breaking TestInfoFromEnvMatchesGit and TestInfoFromEnvPrecedence on Windows runners with the new git. Point them at an empty file instead. Updates git-for-windows/git#6449 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Change-Id: If2b9b6d29344b9280771e507d7d7e6c06f7ab9b0
This commit is contained in:
1 parent
76648a00fd
commit
d80811b882
1 file changed
+8
-1
@@ -17,12 +17,19 @@ import (
|
||||
// the test on error.
|
||||
func gitIn(t *testing.T, dir string, args ...string) string {
|
||||
t.Helper()
|
||||
// Use an empty file rather than os.DevNull, as Git for Windows 2.56.0
|
||||
// rejects "NUL" for GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM.
|
||||
// See https://github.com/git-for-windows/git/issues/6449.
|
||||
emptyConfig := filepath.Join(t.TempDir(), "gitconfig")
|
||||
if err := os.WriteFile(emptyConfig, nil, 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd.Dir = dir
|
||||
cmd.Env = append(os.Environ(),
|
||||
"GIT_AUTHOR_NAME=t", "GIT_AUTHOR_EMAIL=t@t",
|
||||
"GIT_COMMITTER_NAME=t", "GIT_COMMITTER_EMAIL=t@t",
|
||||
"GIT_CONFIG_GLOBAL="+os.DevNull, "GIT_CONFIG_SYSTEM="+os.DevNull,
|
||||
"GIT_CONFIG_GLOBAL="+emptyConfig, "GIT_CONFIG_SYSTEM="+emptyConfig,
|
||||
)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user