From 672e47860281a7f7be0dbda50692924c6f3abd74 Mon Sep 17 00:00:00 2001 From: cezkuj Date: Fri, 17 May 2019 05:53:06 +0000 Subject: [PATCH] Resolving #21 issue. Adding git-dir flag to always execute inside ko's directory in GOPATH --- pkg/commands/version.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/commands/version.go b/pkg/commands/version.go index b5f21bbe54..e07fe7e2b0 100644 --- a/pkg/commands/version.go +++ b/pkg/commands/version.go @@ -17,6 +17,7 @@ package commands import ( "fmt" "log" + "os" "os/exec" "strings" @@ -39,7 +40,8 @@ func addVersion(topLevel *cobra.Command) { func version() { if Version == "" { - hash, err := exec.Command("git", "rev-parse", "HEAD").Output() + gitDir := fmt.Sprintf("--git-dir=%v/src/github.com/google/ko/.git", os.Getenv("GOPATH")) + hash, err := exec.Command("git", gitDir, "rev-parse", "HEAD").Output() if err != nil { log.Fatalf("error during command execution: %v", err) }