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:
parent
d02c8b59f6
commit
84e8c9d168
@ -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
|
||||
|
10
sv/git.go
10
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.
|
||||
|
Loading…
Reference in New Issue
Block a user