diff options
author | Francisco Miamoto <francisco@dorayaki.co> | 2021-09-11 19:19:25 -0300 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-26 17:08:31 +1100 |
commit | b1d6ccddfb7ebcfc44cbfa315d27961b98d48951 (patch) | |
tree | d6f4c756916ff159e45a62d9f21246d07d797b3e | |
parent | 4df003cc4455adc7004c5da4bbcbc4a8b69d47c3 (diff) |
support creating annotated tags
-rw-r--r-- | pkg/commands/tags.go | 4 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 31 | ||||
-rw-r--r-- | pkg/i18n/english.go | 10 |
3 files changed, 41 insertions, 4 deletions
diff --git a/pkg/commands/tags.go b/pkg/commands/tags.go index 9aa327dd3..ae819fbec 100644 --- a/pkg/commands/tags.go +++ b/pkg/commands/tags.go @@ -8,6 +8,10 @@ func (c *GitCommand) CreateLightweightTag(tagName string, commitSha string) erro return c.RunCommand("git tag -- %s %s", c.OSCommand.Quote(tagName), commitSha) } +func (c *GitCommand) CreateAnnotatedTag(tagName, commitSha, msg string) error { + return c.RunCommand("git tag %s %s -m '%s'", tagName, commitSha, msg) +} + func (c *GitCommand) DeleteTag(tagName string) error { return c.RunCommand("git tag -d %s", c.OSCommand.Quote(tagName)) } diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 395b8bf9f..ce2ca9a92 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -579,15 +579,38 @@ func (gui *Gui) handleSquashAllAboveFixupCommits() error { } func (gui *Gui) handleTagCommit() error { - // TODO: bring up menu asking if you want to make a lightweight or annotated tag - // if annotated, switch to a subprocess to create the message - commit := gui.getSelectedLocalCommit() if commit == nil { return nil } - return gui.handleCreateLightweightTag(commit.Sha) + items := []*menuItem{ + {displayString: gui.Tr.LightweightTag, onPress: func() error { + return gui.handleCreateLightweightTag(commit.Sha) + }}, + {displayString: gui.Tr.AnnotatedTag, onPress: func() error { + return gui.handleCreateAnnotatedTag(commit.Sha) + }}, + } + + return gui.createMenu(gui.Tr.TagMenuTitle, items, createMenuOptions{showCancel: false}) +} + +func (gui *Gui) handleCreateAnnotatedTag(commitSha string) error { + return gui.prompt(promptOpts{ + title: gui.Tr.TagNameTitle, + handleConfirm: func(tagname string) error { + return gui.prompt(promptOpts{ + title: gui.Tr.TagMessageTitle, + handleConfirm: func(msg string) error { + if err := gui.GitCommand.WithSpan(gui.Tr.Spans.CreateAnnotatedTag).CreateAnnotatedTag(tagname, commitSha, msg); err != nil { + return gui.surfaceError(err) + } + return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS, TAGS}}) + }, + }) + }, + }) } func (gui *Gui) handleCreateLightweightTag(commitSha string) error { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index a35e9bc47..57d42f430 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -299,7 +299,11 @@ type TranslationSet struct { SetUpstreamMessage string LcEditRemote string LcTagCommit string + TagMenuTitle string TagNameTitle string + TagMessageTitle string + LightweightTag string + AnnotatedTag string LcDeleteTag string DeleteTagTitle string DeleteTagPrompt string @@ -523,6 +527,7 @@ type Spans struct { BulkDeinitialiseSubmodules string UpdateSubmodule string CreateLightweightTag string + CreateAnnotatedTag string DeleteTag string PushTag string NukeWorkingTree string @@ -842,7 +847,11 @@ func englishTranslationSet() TranslationSet { SetUpstreamMessage: "Are you sure you want to set the upstream branch of '{{.checkedOut}}' to '{{.selected}}'", LcEditRemote: "edit remote", LcTagCommit: "tag commit", + TagMenuTitle: "create tag", TagNameTitle: "Tag name:", + TagMessageTitle: "Tag message: ", + AnnotatedTag: "annotated tag", + LightweightTag: "lightweight tag", LcDeleteTag: "delete tag", DeleteTagTitle: "Delete tag", DeleteTagPrompt: "Are you sure you want to delete tag '{{.tagName}}'?", @@ -1018,6 +1027,7 @@ func englishTranslationSet() TranslationSet { CreateFixupCommit: "Create fixup commit", SquashAllAboveFixupCommits: "Squash all above fixup commits", CreateLightweightTag: "Create lightweight tag", + CreateAnnotatedTag: "Create annotated tag", CopyCommitMessageToClipboard: "Copy commit message to clipboard", MoveCommitUp: "Move commit up", MoveCommitDown: "Move commit down", |