mirror of
https://github.com/thegeeklab/git-sv.git
synced 2024-11-21 12:00:40 +00:00
feat: add flag to control tag annotation (#13)
This commit is contained in:
parent
53af856cc5
commit
aafeb36d4a
@ -152,11 +152,15 @@ func (g GitSV) Commit(header, body, footer string) error {
|
||||
}
|
||||
|
||||
// Tag create a git tag.
|
||||
func (g GitSV) Tag(version semver.Version) (string, error) {
|
||||
func (g GitSV) Tag(version semver.Version, annotate 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", "-a", tag, "-m", tagMsg)
|
||||
tagCommand := exec.Command("git", "tag", tag)
|
||||
if annotate {
|
||||
tagCommand = exec.Command("git", "tag", "-a", tag, "-m", tagMsg)
|
||||
}
|
||||
|
||||
if out, err := tagCommand.CombinedOutput(); err != nil {
|
||||
return tag, combinedOutputErr(err, out)
|
||||
}
|
||||
|
@ -9,7 +9,18 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func TagHandler(g app.GitSV) cli.ActionFunc {
|
||||
func TagFlags(settings *app.TagSettings) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "annotate",
|
||||
Aliases: []string{"a"},
|
||||
Usage: "ignore size parameter, get changelog for every tag",
|
||||
Destination: &settings.Annotate,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TagHandler(g app.GitSV, settings *app.TagSettings) cli.ActionFunc {
|
||||
return func(c *cli.Context) error {
|
||||
lastTag := g.LastTag()
|
||||
|
||||
@ -30,7 +41,7 @@ func TagHandler(g app.GitSV) cli.ActionFunc {
|
||||
return nil
|
||||
}
|
||||
|
||||
tagname, err := g.Tag(*nextVer)
|
||||
tagname, err := g.Tag(*nextVer, settings.Annotate)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error generating tag version: %s: %w", nextVer.String(), err)
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ type Settings struct {
|
||||
ReleaseNotesSettings ReleaseNotesSettings
|
||||
CommitNotesSettings CommitNotesSettings
|
||||
CommitLogSettings CommitLogSettings
|
||||
TagSettings TagSettings
|
||||
}
|
||||
|
||||
type ChangelogSettings struct {
|
||||
@ -48,6 +49,10 @@ type CommitLogSettings struct {
|
||||
End string
|
||||
}
|
||||
|
||||
type TagSettings struct {
|
||||
Annotate bool
|
||||
}
|
||||
|
||||
// Config cli yaml config.
|
||||
type Config struct {
|
||||
Version string `yaml:"version"`
|
||||
|
@ -116,7 +116,8 @@ When flag range is "date", if "end" is YYYY-MM-DD the range will be inclusive.`,
|
||||
Name: "tag",
|
||||
Aliases: []string{"tg"},
|
||||
Usage: "generate tag with version based on git commit messages",
|
||||
Action: commands.TagHandler(gsv),
|
||||
Action: commands.TagHandler(gsv, &gsv.Settings.TagSettings),
|
||||
Flags: commands.TagFlags(&gsv.Settings.TagSettings),
|
||||
},
|
||||
{
|
||||
Name: "commit",
|
||||
|
Loading…
Reference in New Issue
Block a user