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:
parent
289921d278
commit
4ca2bb2101
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user