diff --git a/build/git.go b/build/git.go index 67aea527..8cabbb07 100644 --- a/build/git.go +++ b/build/git.go @@ -24,13 +24,13 @@ func getGitAttributes(ctx context.Context, contextPath string, dockerfilePath st if v, ok := os.LookupEnv("BUILDX_GIT_LABELS"); ok { if v == "full" { // backward compatibility with old "full" mode setGitLabels = true - } else if v, _ := strconv.ParseBool(v); v { + } else if v, err := strconv.ParseBool(v); err == nil { setGitLabels = v } } setGitInfo := true if v, ok := os.LookupEnv("BUILDX_GIT_INFO"); ok { - if v, _ := strconv.ParseBool(v); v { + if v, err := strconv.ParseBool(v); err == nil { setGitInfo = v } } diff --git a/build/git_test.go b/build/git_test.go index 5dc630f4..6b531837 100644 --- a/build/git_test.go +++ b/build/git_test.go @@ -43,6 +43,12 @@ func TestGetGitAttributes(t *testing.T) { "vcs:revision", }, }, + { + name: "none", + envGitLabels: "false", + envGitInfo: "false", + expected: []string{}, + }, { name: "gitinfo", envGitLabels: "false",