mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-09 13:36:56 +02:00
refactor: simplified code
This commit is contained in:
parent
9d4be131cf
commit
abe90e9f5f
@ -2,7 +2,6 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"os/exec"
|
||||
"strings"
|
||||
@ -18,21 +17,17 @@ func IsRepo() bool {
|
||||
|
||||
// Run runs a git command and returns its output or errors
|
||||
func Run(args ...string) (string, error) {
|
||||
// TODO: use exex.CommandContext here and refactor.
|
||||
/* #nosec */
|
||||
var cmd = exec.Command("git", args...)
|
||||
log.WithField("args", args).Debug("running git")
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
err := cmd.Run()
|
||||
log.WithField("stdout", stdout.String()).
|
||||
WithField("stderr", stderr.String()).
|
||||
bts, err := cmd.CombinedOutput()
|
||||
log.WithField("output", string(bts)).
|
||||
Debug("git result")
|
||||
if err != nil {
|
||||
return "", errors.New(stderr.String())
|
||||
return "", errors.New(string(bts))
|
||||
}
|
||||
return stdout.String(), nil
|
||||
return string(bts), nil
|
||||
}
|
||||
|
||||
// Clean the output
|
||||
|
Loading…
x
Reference in New Issue
Block a user