0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-11-24 21:20:40 +00:00
git-sv/app/commands/currentversion.go
renovate[bot] 2d2de1a5e0
chore(deps): update golang devdeps non-major (#55)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Robert Kaussow <mail@thegeeklab.de>
2024-02-12 09:09:42 +01:00

25 lines
514 B
Go

package commands
import (
"fmt"
"github.com/thegeeklab/git-sv/app"
"github.com/thegeeklab/git-sv/sv"
"github.com/urfave/cli/v2"
)
func CurrentVersionHandler(gsv app.GitSV) cli.ActionFunc {
return func(_ *cli.Context) error {
lastTag := gsv.LastTag()
currentVer, err := sv.ToVersion(lastTag)
if err != nil {
return fmt.Errorf("error parsing version: %s from git tag: %w", lastTag, err)
}
fmt.Printf("%d.%d.%d\n", currentVer.Major(), currentVer.Minor(), currentVer.Patch())
return nil
}
}