1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

erroring if version is invalid

This commit is contained in:
Carlos Alexandro Becker 2017-01-30 08:08:42 -02:00
parent 289921d278
commit 4ca2bb2101
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940

View File

@ -1,11 +1,21 @@
package git
import (
"regexp"
"strings"
"github.com/goreleaser/goreleaser/context"
)
// ErrInvalidVersionFormat is return when the version isnt in a valid format
type ErrInvalidVersionFormat struct {
version string
}
func (e ErrInvalidVersionFormat) Error() string {
return e.version + " is not in a valid version format"
}
// Pipe for brew deployment
type Pipe struct{}
@ -36,5 +46,8 @@ func (Pipe) Run(ctx *context.Context) (err error) {
}
// removes usual `v` prefix
ctx.Version = strings.TrimPrefix(tag, "v")
if matches, err := regexp.MatchString("[0-9.]+", ctx.Version); !matches || err != nil {
return ErrInvalidVersionFormat{ctx.Version}
}
return
}