mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
improved git pipe code
This commit is contained in:
parent
a5fe2e48c3
commit
d7f0147edf
@ -77,7 +77,7 @@ func (Pipe) Run(ctx *context.Context) (err error) {
|
|||||||
log.Println("Skipped validations because --skip-validate is set")
|
log.Println("Skipped validations because --skip-validate is set")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return validate(commit, tag, ctx.Version, ctx.Snapshot)
|
return validate(ctx, commit, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setVersion(ctx *context.Context, tag, commit string) (err error) {
|
func setVersion(ctx *context.Context, tag, commit string) (err error) {
|
||||||
@ -132,23 +132,21 @@ func getSnapshotName(ctx *context.Context, tag, commit string) (string, error) {
|
|||||||
return out.String(), err
|
return out.String(), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func validate(commit, tag, version string, isSnapshot bool) error {
|
func validate(ctx *context.Context, commit, tag string) error {
|
||||||
if !isSnapshot {
|
|
||||||
matches, err := regexp.MatchString("^[0-9.]+", version)
|
|
||||||
if err != nil || !matches {
|
|
||||||
return ErrInvalidVersionFormat{version}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out, err := git("status", "-s")
|
out, err := git("status", "-s")
|
||||||
if strings.TrimSpace(out) != "" || err != nil {
|
if strings.TrimSpace(out) != "" || err != nil {
|
||||||
return ErrDirty{out}
|
return ErrDirty{out}
|
||||||
}
|
}
|
||||||
if !isSnapshot {
|
if ctx.Snapshot {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if !regexp.MustCompile("^[0-9.]+").MatchString(ctx.Version) {
|
||||||
|
return ErrInvalidVersionFormat{ctx.Version}
|
||||||
|
}
|
||||||
_, err = cleanGit("describe", "--exact-match", "--tags", "--match", tag)
|
_, err = cleanGit("describe", "--exact-match", "--tags", "--match", tag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrWrongRef{commit, tag}
|
return ErrWrongRef{commit, tag}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user