1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00

54 lines
1.0 KiB
Go
Raw Normal View History

2017-01-14 12:34:22 -02:00
package git
2017-01-29 21:55:32 -02:00
import (
2017-01-30 08:08:42 -02:00
"regexp"
2017-01-29 21:55:32 -02:00
"strings"
"github.com/goreleaser/goreleaser/context"
)
2017-01-14 12:34:22 -02:00
2017-01-30 08:08:42 -02:00
// 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"
}
2017-01-14 12:34:22 -02:00
// Pipe for brew deployment
type Pipe struct{}
2017-01-14 19:41:32 +01:00
// Description of the pipe
2017-01-14 15:14:35 -02:00
func (Pipe) Description() string {
2017-01-19 10:04:41 +01:00
return "Getting Git info"
2017-01-14 12:34:22 -02:00
}
// Run the pipe
2017-01-14 14:06:57 -02:00
func (Pipe) Run(ctx *context.Context) (err error) {
2017-01-14 12:34:22 -02:00
tag, err := currentTag()
if err != nil {
return
}
previous, err := previousTag(tag)
if err != nil {
return
}
log, err := log(previous, tag)
if err != nil {
return
}
2017-01-18 15:08:48 -02:00
ctx.Git = context.GitInfo{
2017-01-14 14:06:57 -02:00
CurrentTag: tag,
PreviousTag: previous,
Diff: log,
}
2017-01-29 21:55:32 -02:00
// removes usual `v` prefix
ctx.Version = strings.TrimPrefix(tag, "v")
2017-01-30 10:01:05 -02:00
if matches, err := regexp.MatchString("^[0-9.]+", ctx.Version); !matches || err != nil {
2017-01-30 08:08:42 -02:00
return ErrInvalidVersionFormat{ctx.Version}
}
2017-01-14 12:34:22 -02:00
return
}