mirror of
https://github.com/thegeeklab/git-sv.git
synced 2024-11-21 12:00:40 +00:00
feat: add flag to create local tag only (#14)
This commit is contained in:
parent
aafeb36d4a
commit
a2f25f042e
@ -152,19 +152,23 @@ func (g GitSV) Commit(header, body, footer string) error {
|
||||
}
|
||||
|
||||
// Tag create a git tag.
|
||||
func (g GitSV) Tag(version semver.Version, annotate bool) (string, error) {
|
||||
func (g GitSV) Tag(version semver.Version, annotate, local bool) (string, error) {
|
||||
tag := fmt.Sprintf(*g.Config.Tag.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", tag)
|
||||
if annotate {
|
||||
tagCommand = exec.Command("git", "tag", "-a", tag, "-m", tagMsg)
|
||||
tagCommand.Args = append(tagCommand.Args, "-a", "-m", tagMsg)
|
||||
}
|
||||
|
||||
if out, err := tagCommand.CombinedOutput(); err != nil {
|
||||
return tag, combinedOutputErr(err, out)
|
||||
}
|
||||
|
||||
if local {
|
||||
return tag, nil
|
||||
}
|
||||
|
||||
pushCommand := exec.Command("git", "push", "origin", tag)
|
||||
if out, err := pushCommand.CombinedOutput(); err != nil {
|
||||
return tag, combinedOutputErr(err, out)
|
||||
|
@ -14,9 +14,14 @@ func TagFlags(settings *app.TagSettings) []cli.Flag {
|
||||
&cli.BoolFlag{
|
||||
Name: "annotate",
|
||||
Aliases: []string{"a"},
|
||||
Usage: "ignore size parameter, get changelog for every tag",
|
||||
Usage: "make an annotated tag object",
|
||||
Destination: &settings.Annotate,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "local",
|
||||
Usage: "create local tag only",
|
||||
Destination: &settings.Local,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +46,7 @@ func TagHandler(g app.GitSV, settings *app.TagSettings) cli.ActionFunc {
|
||||
return nil
|
||||
}
|
||||
|
||||
tagname, err := g.Tag(*nextVer, settings.Annotate)
|
||||
tagname, err := g.Tag(*nextVer, settings.Annotate, settings.Local)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error generating tag version: %s: %w", nextVer.String(), err)
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ type CommitLogSettings struct {
|
||||
|
||||
type TagSettings struct {
|
||||
Annotate bool
|
||||
Local bool
|
||||
}
|
||||
|
||||
// Config cli yaml config.
|
||||
|
Loading…
Reference in New Issue
Block a user