Skip to content

Commit 3ec76e5

Browse files
authored
Print stderr when git fails (#15)
1 parent ac56db2 commit 3ec76e5

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

cmd/get_targets.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ $ bazel-differ get-targets -w path/to/workspace -b $(which bazel) -s START_HASH
6060

6161
func getHashes(revision string, gitClient internal.GitClient, cacheManager cache.HashCacheManager,
6262
targetHasher internal.TargetHashingClient) map[string]string {
63-
err := gitClient.Checkout(revision)
64-
ExitIfError(err, fmt.Sprintf("Unable to checkout revision: %s", revision))
63+
output, err := gitClient.Checkout(revision)
64+
ExitIfError(err, fmt.Sprintf("Unable to checkout revision: %s. %s", revision, output))
6565

6666
var seedfilePaths = make(map[string]bool)
6767
if SeedFilepaths != "" {

internal/git_client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
)
66

77
type GitClient interface {
8-
Checkout(hash string) error
8+
Checkout(hash string) (string, error)
99
}
1010

1111
type gitClient struct {
@@ -18,8 +18,8 @@ func NewGitClient(dir string) GitClient {
1818
}
1919
}
2020

21-
func (g gitClient) Checkout(hash string) error {
21+
func (g gitClient) Checkout(hash string) (string, error) {
2222
cmd := exec.Command("git", "-C", g.dir, "checkout", hash, "--quiet")
23-
_, err := cmd.Output()
24-
return err
23+
output, err := cmd.CombinedOutput()
24+
return string(output), err
2525
}

0 commit comments

Comments
 (0)