diff --git a/cmd/git-sv/config.go b/cmd/git-sv/config.go index b9d9b26..a7ed36f 100644 --- a/cmd/git-sv/config.go +++ b/cmd/git-sv/config.go @@ -1,7 +1,6 @@ package main import ( - "errors" "fmt" "io/ioutil" "log" @@ -24,7 +23,7 @@ func loadEnvConfig() EnvConfig { var c EnvConfig err := envconfig.Process("", &c) if err != nil { - log.Fatal(err.Error()) + log.Fatal("failed to load env config, error: ", err.Error()) } return c } @@ -43,11 +42,16 @@ func getRepoPath() (string, error) { cmd := exec.Command("git", "rev-parse", "--show-toplevel") out, err := cmd.CombinedOutput() if err != nil { - return "", errors.New(string(out)) + return "", combinedOutputErr(err, out) } return strings.TrimSpace(string(out)), nil } +func combinedOutputErr(err error, out []byte) error { + msg := strings.Split(string(out), "\n") + return fmt.Errorf("%v - %s", err, msg[0]) +} + func loadConfig(filepath string) (Config, error) { content, rerr := ioutil.ReadFile(filepath) if rerr != nil { diff --git a/cmd/git-sv/main.go b/cmd/git-sv/main.go index a78fded..f446991 100644 --- a/cmd/git-sv/main.go +++ b/cmd/git-sv/main.go @@ -27,19 +27,19 @@ func main() { if envCfg.Home != "" { if homeCfg, err := loadConfig(filepath.Join(envCfg.Home, configFilename)); err == nil { if merr := merge(&cfg, homeCfg); merr != nil { - log.Fatal(merr) + log.Fatal("failed to merge user config, error: ", merr) } } } repoPath, rerr := getRepoPath() if rerr != nil { - log.Fatal(rerr) + log.Fatal("failed to get repository path, error: ", rerr) } if repoCfg, err := loadConfig(filepath.Join(repoPath, repoConfigFilename)); err == nil { if merr := merge(&cfg, repoCfg); merr != nil { - log.Fatal(merr) + log.Fatal("failed to merge repo config, error: ", merr) } if len(repoCfg.ReleaseNotes.Headers) > 0 { // mergo is merging maps, headers will be overwritten cfg.ReleaseNotes.Headers = repoCfg.ReleaseNotes.Headers @@ -165,6 +165,6 @@ func main() { } if apperr := app.Run(os.Args); apperr != nil { - log.Fatal(apperr) + log.Fatal("failed to run cli, error: ", apperr) } }