Improved and simplified error handling around execution of git commands.
This commit is contained in:
parent
1cd8607d34
commit
5d60e0ca4d
1 changed files with 4 additions and 11 deletions
15
main.go
15
main.go
|
@ -263,25 +263,18 @@ func createTag(tagName string, sign bool) error {
|
||||||
if sign {
|
if sign {
|
||||||
signFlag = "-s"
|
signFlag = "-s"
|
||||||
}
|
}
|
||||||
cmd := exec.Command("git", "tag", signFlag, "-m", "Version "+tagName, tagName)
|
out, err := exec.Command("git", "tag", signFlag, "-m", "Version "+tagName, tagName).CombinedOutput()
|
||||||
stderr, err := cmd.StderrPipe()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
fmt.Fprintln(os.Stderr, string(out))
|
||||||
}
|
|
||||||
if err := cmd.Start(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
out, _ := io.ReadAll(stderr)
|
|
||||||
fmt.Fprintf(os.Stderr, string(out))
|
|
||||||
if err := cmd.Wait(); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVersion(versionPrefix string) (*semver.Version, error) {
|
func getVersion(versionPrefix string) (*semver.Version, error) {
|
||||||
out, err := exec.Command("git", "tag").Output()
|
out, err := exec.Command("git", "tag").CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, string(out))
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var latest *semver.Version
|
var latest *semver.Version
|
||||||
|
|
Loading…
Reference in a new issue