1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00

improved status output

This commit is contained in:
Carlos Alexandro Becker 2017-01-31 11:08:12 -02:00
parent 3c4c55cf2e
commit 2938132987
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940

View File

@ -15,7 +15,7 @@ type ErrDirty struct {
}
func (e ErrDirty) Error() string {
return "git is currently in a dirty state: " + e.status
return "git is currently in a dirty state:\n" + e.status
}
// ErrWrongRef happens when the HEAD reference is different from the tag being built
@ -24,7 +24,7 @@ type ErrWrongRef struct {
}
func (e ErrWrongRef) Error() string {
return "current tag ref is different from HEAD ref: " + e.status
return "current tag ref is different from HEAD ref:\n" + e.status
}
// Pipe to make sure we are in the latest Git tag as source.
@ -40,28 +40,13 @@ func (p Pipe) Description() string {
func (p Pipe) Run(ctx *context.Context) error {
cmd := exec.Command("git", "diff-index", "--quiet", "HEAD", "--")
if err := cmd.Run(); err != nil {
status, err := status()
if err != nil {
return err
}
return ErrDirty{status}
bts, _ := exec.Command("git", "diff-index", "HEAD", "--").CombinedOutput()
return ErrDirty{string(bts)}
}
cmd = exec.Command("git", "describe", "--exact-match", "--tags", "--match", ctx.Git.CurrentTag)
if err := cmd.Run(); err != nil {
status, err := status()
if err != nil {
return err
}
return ErrWrongRef{status}
if bts, err := cmd.CombinedOutput(); err != nil {
return ErrWrongRef{string(bts)}
}
return nil
}
func status() (string, error) {
bts, err := exec.Command("git", "status", "-sb").CombinedOutput()
if err != nil {
return "", err
}
return "\n\n" + string(bts), nil
}