mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-23 21:19:17 +02:00
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package git
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"regexp/syntax"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/tmpl"
|
|
)
|
|
|
|
// ErrDirty happens when the repo has uncommitted/unstashed changes.
|
|
type ErrDirty struct {
|
|
status string
|
|
}
|
|
|
|
func (e ErrDirty) Error() string {
|
|
return fmt.Sprintf("git is in a dirty state\nPlease check in your pipeline what can be changing the following files:\n%v\nLearn more at https://goreleaser.com/errors/dirty\n", e.status)
|
|
}
|
|
|
|
// ErrWrongRef happens when the HEAD reference is different from the tag being built.
|
|
type ErrWrongRef struct {
|
|
commit, tag string
|
|
}
|
|
|
|
func (e ErrWrongRef) Error() string {
|
|
return fmt.Sprintf("git tag %v was not made against commit %v", e.tag, e.commit)
|
|
}
|
|
|
|
// ErrNoTag happens if the underlying git repository doesn't contain any tags
|
|
// but no snapshot-release was requested.
|
|
var ErrNoTag = errors.New("git doesn't contain any tags. Either add a tag or use --snapshot")
|
|
|
|
// ErrNotRepository happens if you try to run goreleaser against a folder
|
|
// which is not a git repository.
|
|
var ErrNotRepository = errors.New("current folder is not a git repository")
|
|
|
|
// ErrNoGit happens when git is not present in PATH.
|
|
var ErrNoGit = errors.New("git not present in PATH")
|
|
|
|
// shouldErr returns true if the errors are template or regex related.
|
|
func shouldErr(err error) bool {
|
|
if errors.As(err, &tmpl.Error{}) {
|
|
return true
|
|
}
|
|
se := &syntax.Error{}
|
|
return errors.As(err, &se)
|
|
}
|