From 84e8c9d168610c33d1f0be704884cfbfd41378cc Mon Sep 17 00:00:00 2001 From: Beatriz Vieira Date: Fri, 24 Sep 2021 17:59:38 -0300 Subject: [PATCH] feat: print tag name on git sv tag --- cmd/git-sv/handlers.go | 6 +++--- sv/git.go | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/git-sv/handlers.go b/cmd/git-sv/handlers.go index 36de37a..d37cfb5 100644 --- a/cmd/git-sv/handlers.go +++ b/cmd/git-sv/handlers.go @@ -263,9 +263,9 @@ func tagHandler(git sv.Git, semverProcessor sv.SemVerCommitsProcessor) func(c *c } nextVer, _ := semverProcessor.NextVersion(currentVer, commits) - fmt.Printf("%d.%d.%d\n", nextVer.Major(), nextVer.Minor(), nextVer.Patch()) - - if err := git.Tag(nextVer); err != nil { + tagname, err := git.Tag(nextVer) + fmt.Println(tagname) + if err != nil { return fmt.Errorf("error generating tag version: %s, message: %v", nextVer.String(), err) } return nil diff --git a/sv/git.go b/sv/git.go index 68dcded..bab6d14 100644 --- a/sv/git.go +++ b/sv/git.go @@ -23,7 +23,7 @@ type Git interface { LastTag() string Log(lr LogRange) ([]GitCommitLog, error) Commit(header, body, footer string) error - Tag(version semver.Version) error + Tag(version semver.Version) (string, error) Tags() ([]GitTag, error) Branch() string IsDetached() (bool, error) @@ -123,20 +123,20 @@ func (g GitImpl) Commit(header, body, footer string) error { } // Tag create a git tag. -func (g GitImpl) Tag(version semver.Version) error { +func (g GitImpl) Tag(version semver.Version) (string, error) { tag := fmt.Sprintf(g.tagCfg.Pattern, version.Major(), version.Minor(), version.Patch()) tagMsg := fmt.Sprintf("Version %d.%d.%d", version.Major(), version.Minor(), version.Patch()) tagCommand := exec.Command("git", "tag", "-a", tag, "-m", tagMsg) if out, err := tagCommand.CombinedOutput(); err != nil { - return combinedOutputErr(err, out) + return tag, combinedOutputErr(err, out) } pushCommand := exec.Command("git", "push", "origin", tag) if out, err := pushCommand.CombinedOutput(); err != nil { - return combinedOutputErr(err, out) + return tag, combinedOutputErr(err, out) } - return nil + return tag, nil } // Tags list repository tags.