Skip to content

Commit

Permalink
Merge pull request #23153 from AkihiroSuda/fix23152PkgGitutils
Browse files Browse the repository at this point in the history
Fix gitconfig dependency in pkg/gitutils.TestCheckoutGit
  • Loading branch information
vdemeester committed Jun 2, 2016
2 parents 09033b8 + efc250b commit f69353a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/gitutils/gitutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"path/filepath"
"reflect"
"runtime"
"strings"
"testing"
)

Expand Down Expand Up @@ -70,15 +71,30 @@ 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 {
t.Fatal(err)
}
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"
}

Expand Down

0 comments on commit f69353a

Please sign in to comment.