Skip to content

Commit

Permalink
[fix] fixing no git error details issue
Browse files Browse the repository at this point in the history
  • Loading branch information
xpunch committed Jan 27, 2022
1 parent a0337f8 commit b527c52
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.2.0 (2022/01/27)

### Bug Fixes
- fixing no git error details issue

# 1.1.0 (2022/01/17)

### Features
Expand Down
12 changes: 8 additions & 4 deletions git.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import (

func git(dir string, args ...string) (string, error) {
cmd := exec.Command("git", args...)
var out bytes.Buffer
cmd.Stdout = &out
var stdout bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr
cmd.Dir = dir
if *verbose {
fmt.Println(cmd.String())
}
err := cmd.Run()
return out.String(), err
if err := cmd.Run(); err != nil {
return "", fmt.Errorf(stderr.String())
}
return stdout.String(), nil
}

// fetchGitRepository will fetch latest commits and tags
Expand Down
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ func main() {
flag.Parse()
if *fetch {
if err := fetchGitRepository(); err != nil {
panic(err)
fmt.Println(err)
return
}
}
gittags, err := getGitTags()
if err != nil {
panic(err)
fmt.Println(err)
return
}
if *verbose {
fmt.Println(gittags)
Expand Down Expand Up @@ -128,6 +130,7 @@ func main() {
}
}
if err := ioutil.WriteFile(*output, buf.Bytes(), os.ModePerm); err != nil {
panic(err)
fmt.Println(err)
return
}
}

0 comments on commit b527c52

Please sign in to comment.