Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit 60e5079

Browse files
Fix git command error tracking
1 parent deefef0 commit 60e5079

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

git/git.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (g *GitClient) RemoteInfos() ([]*RemoteInfo, error) {
2626
// Get remote repositorys
2727
remotes, err := gitOutput("remote")
2828
if err != nil {
29-
return nil, fmt.Errorf("Failed collect git remove infos. %s", err)
29+
return nil, fmt.Errorf("Failed collect git remote. %s", err)
3030
}
3131
if len(remotes) == 0 {
3232
return nil, errors.New("No remote setting in this repository")
@@ -162,12 +162,16 @@ var execCommand = exec.Command
162162

163163
func gitOutput(input ...string) (outputs []string, err error) {
164164
output, err := execCommand("git", input...).CombinedOutput()
165+
if err != nil {
166+
return nil, fmt.Errorf("failed git command.\n%s\n%s", output, err)
167+
}
168+
165169
for _, line := range strings.Split(string(output), "\n") {
166170
if strings.TrimSpace(line) != "" {
167171
outputs = append(outputs, string(line))
168172
}
169173
}
170-
return outputs, err
174+
return outputs, nil
171175
}
172176

173177
func CommentChar() string {

0 commit comments

Comments
 (0)