Merge pull request #23153 from AkihiroSuda/fix23152PkgGitutils

Fix gitconfig dependency in pkg/gitutils.TestCheckoutGit
This commit is contained in:
Vincent Demeester 2016-06-02 17:21:38 +02:00
commit c453d36187

View file

@ -10,6 +10,7 @@ import (
"path/filepath"
"reflect"
"runtime"
"strings"
"testing"
)
@ -70,6 +71,16 @@ func TestCloneArgsStripFragment(t *testing.T) {
}
}
func gitGetConfig(name string) string {
b, err := git([]string{"config", "--get", name}...)
if err != nil {
// since we are interested in empty or non empty string,
// we can safely ignore the err here.
return ""
}
return strings.TrimSpace(string(b))
}
func TestCheckoutGit(t *testing.T) {
root, err := ioutil.TempDir("", "docker-build-git-checkout")
if err != nil {
@ -77,8 +88,13 @@ func TestCheckoutGit(t *testing.T) {
}
defer os.RemoveAll(root)
autocrlf := gitGetConfig("core.autocrlf")
if !(autocrlf == "true" || autocrlf == "false" ||
autocrlf == "input" || autocrlf == "") {
t.Logf("unknown core.autocrlf value: \"%s\"", autocrlf)
}
eol := "\n"
if runtime.GOOS == "windows" {
if autocrlf == "true" {
eol = "\r\n"
}