mirror of
https://github.com/thegeeklab/git-sv.git
synced 2024-11-14 07:40:40 +00:00
37 lines
790 B
Go
37 lines
790 B
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/thegeeklab/git-sv/app"
|
|
"github.com/thegeeklab/git-sv/sv"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func TagHandler(g app.GitSV) cli.ActionFunc {
|
|
return func(c *cli.Context) error {
|
|
lastTag := g.LastTag()
|
|
|
|
currentVer, err := sv.ToVersion(lastTag)
|
|
if err != nil {
|
|
return fmt.Errorf("error parsing version: %s from git tag: %w", lastTag, err)
|
|
}
|
|
|
|
commits, err := g.Log(app.NewLogRange(app.TagRange, lastTag, ""))
|
|
if err != nil {
|
|
return fmt.Errorf("error getting git log: %w", err)
|
|
}
|
|
|
|
nextVer, _ := g.CommitProcessor.NextVersion(currentVer, commits)
|
|
tagname, err := g.Tag(*nextVer)
|
|
|
|
fmt.Println(tagname)
|
|
|
|
if err != nil {
|
|
return fmt.Errorf("error generating tag version: %s: %w", nextVer.String(), err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
}
|