0
0
mirror of https://github.com/thegeeklab/git-sv.git synced 2024-11-24 01:00:39 +00:00

feat: print tag name on git sv tag

This commit is contained in:
Beatriz Vieira 2021-09-24 17:59:38 -03:00
parent d02c8b59f6
commit 84e8c9d168
2 changed files with 8 additions and 8 deletions

View File

@ -263,9 +263,9 @@ func tagHandler(git sv.Git, semverProcessor sv.SemVerCommitsProcessor) func(c *c
} }
nextVer, _ := semverProcessor.NextVersion(currentVer, commits) nextVer, _ := semverProcessor.NextVersion(currentVer, commits)
fmt.Printf("%d.%d.%d\n", nextVer.Major(), nextVer.Minor(), nextVer.Patch()) tagname, err := git.Tag(nextVer)
fmt.Println(tagname)
if err := git.Tag(nextVer); err != nil { if err != nil {
return fmt.Errorf("error generating tag version: %s, message: %v", nextVer.String(), err) return fmt.Errorf("error generating tag version: %s, message: %v", nextVer.String(), err)
} }
return nil return nil

View File

@ -23,7 +23,7 @@ type Git interface {
LastTag() string LastTag() string
Log(lr LogRange) ([]GitCommitLog, error) Log(lr LogRange) ([]GitCommitLog, error)
Commit(header, body, footer string) error Commit(header, body, footer string) error
Tag(version semver.Version) error Tag(version semver.Version) (string, error)
Tags() ([]GitTag, error) Tags() ([]GitTag, error)
Branch() string Branch() string
IsDetached() (bool, error) IsDetached() (bool, error)
@ -123,20 +123,20 @@ func (g GitImpl) Commit(header, body, footer string) error {
} }
// Tag create a git tag. // 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()) 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()) tagMsg := fmt.Sprintf("Version %d.%d.%d", version.Major(), version.Minor(), version.Patch())
tagCommand := exec.Command("git", "tag", "-a", tag, "-m", tagMsg) tagCommand := exec.Command("git", "tag", "-a", tag, "-m", tagMsg)
if out, err := tagCommand.CombinedOutput(); err != nil { if out, err := tagCommand.CombinedOutput(); err != nil {
return combinedOutputErr(err, out) return tag, combinedOutputErr(err, out)
} }
pushCommand := exec.Command("git", "push", "origin", tag) pushCommand := exec.Command("git", "push", "origin", tag)
if out, err := pushCommand.CombinedOutput(); err != nil { 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. // Tags list repository tags.