Skip to content

Commit

Permalink
Print stderr when git fails (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
bretwalker authored Jul 18, 2023
1 parent ac56db2 commit 3ec76e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/get_targets.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ $ bazel-differ get-targets -w path/to/workspace -b $(which bazel) -s START_HASH

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

var seedfilePaths = make(map[string]bool)
if SeedFilepaths != "" {
Expand Down
8 changes: 4 additions & 4 deletions internal/git_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

type GitClient interface {
Checkout(hash string) error
Checkout(hash string) (string, error)
}

type gitClient struct {
Expand All @@ -18,8 +18,8 @@ func NewGitClient(dir string) GitClient {
}
}

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

0 comments on commit 3ec76e5

Please sign in to comment.