mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-19 20:57:53 +02:00
parent
946a5edb75
commit
6e94482a23
@ -4,9 +4,6 @@ install: make setup
|
|||||||
script:
|
script:
|
||||||
- make ci
|
- make ci
|
||||||
after_success:
|
after_success:
|
||||||
- test -n "$TRAVIS_TAG" && gem install fpm
|
- test -n "$TRAVIS_TAG" && gem install fpm && go run main.go
|
||||||
- git status -sb
|
|
||||||
- test -n "$TRAVIS_TAG" && go run main.go
|
|
||||||
- git status -sb
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
@ -4,17 +4,28 @@
|
|||||||
package source
|
package source
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"github.com/goreleaser/goreleaser/context"
|
"github.com/goreleaser/goreleaser/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrDirty happens when the repo has uncommitted/unstashed changes
|
// ErrDirty happens when the repo has uncommitted/unstashed changes
|
||||||
var ErrDirty = errors.New("git is currently in a dirty state, commit or stash your changes to continue")
|
type ErrDirty struct {
|
||||||
|
status string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrDirty) Error() string {
|
||||||
|
return "git is currently in a dirty state: " + e.status
|
||||||
|
}
|
||||||
|
|
||||||
// ErrWrongRef happens when the HEAD reference is different from the tag being built
|
// ErrWrongRef happens when the HEAD reference is different from the tag being built
|
||||||
var ErrWrongRef = errors.New("current tag ref is different from HEAD ref, checkout the latest tag to continue")
|
type ErrWrongRef struct {
|
||||||
|
status string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ErrWrongRef) Error() string {
|
||||||
|
return "current tag ref is different from HEAD ref: " + e.status
|
||||||
|
}
|
||||||
|
|
||||||
// Pipe to make sure we are in the latest Git tag as source.
|
// Pipe to make sure we are in the latest Git tag as source.
|
||||||
type Pipe struct{}
|
type Pipe struct{}
|
||||||
@ -29,12 +40,28 @@ func (p Pipe) Description() string {
|
|||||||
func (p Pipe) Run(ctx *context.Context) error {
|
func (p Pipe) Run(ctx *context.Context) error {
|
||||||
cmd := exec.Command("git", "diff-index", "--quiet", "HEAD", "--")
|
cmd := exec.Command("git", "diff-index", "--quiet", "HEAD", "--")
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
return ErrDirty
|
status, err := status()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return ErrDirty{status}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = exec.Command("git", "describe", "--exact-match", "--tags", "--match", ctx.Git.CurrentTag)
|
cmd = exec.Command("git", "describe", "--exact-match", "--tags", "--match", ctx.Git.CurrentTag)
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
return ErrWrongRef
|
status, err := status()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return ErrWrongRef{status}
|
||||||
}
|
}
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user