mirror of
https://github.com/thegeeklab/git-sv.git
synced 2024-11-26 03:40:39 +00:00
25 lines
529 B
Go
25 lines
529 B
Go
|
package commands
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"github.com/thegeeklab/git-sv/v2/app"
|
||
|
"github.com/thegeeklab/git-sv/v2/sv"
|
||
|
"github.com/urfave/cli/v2"
|
||
|
)
|
||
|
|
||
|
func CurrentVersionHandler(gsv app.GitSV) cli.ActionFunc {
|
||
|
return func(c *cli.Context) error {
|
||
|
lastTag := gsv.LastTag()
|
||
|
|
||
|
currentVer, err := sv.ToVersion(lastTag)
|
||
|
if err != nil {
|
||
|
return fmt.Errorf("error parsing version: %s from git tag, message: %w", lastTag, err)
|
||
|
}
|
||
|
|
||
|
fmt.Printf("%d.%d.%d\n", currentVer.Major(), currentVer.Minor(), currentVer.Patch())
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
}
|