Merge pull request #23153 from AkihiroSuda/fix23152PkgGitutils

Fix gitconfig dependency in pkg/gitutils.TestCheckoutGit
Upstream-commit: f69353a364e0ec6ddb0cff3991ee0b44d87285c1
Component: engine
This commit is contained in:
Vincent Demeester
2016-06-02 17:21:38 +02:00
@@ -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"
}