Skip to content

Commit

Permalink
Resolving ko-build#21 issue. Adding git-dir flag to always execute in…
Browse files Browse the repository at this point in the history
…side ko's directory in GOPATH
  • Loading branch information
cezkuj committed May 17, 2019
1 parent 0aca6f6 commit 672e478
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package commands
import (
"fmt"
"log"
"os"
"os/exec"
"strings"

Expand All @@ -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)
}
Expand Down

0 comments on commit 672e478

Please sign in to comment.