diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-02-20 18:20:16 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-20 18:20:16 +1100 |
commit | 9e1e20fef2af6210e799a6bc965fc7fea62e5857 (patch) | |
tree | 2aff4643da0d42d1a6f13425b6fab330613a1a91 /pkg/gui/controllers | |
parent | 1c3db24e447b63d6507c2dceb0d21db768d1a6f5 (diff) | |
parent | 4b49bd406fb5d179d9944746c107b36e2e74068c (diff) |
Merge pull request #2421 from Ryooooooga/tag-on-branch
Diffstat (limited to 'pkg/gui/controllers')
-rw-r--r-- | pkg/gui/controllers/branches_controller.go | 9 | ||||
-rw-r--r-- | pkg/gui/controllers/helpers/tags_helper.go | 14 |
2 files changed, 16 insertions, 7 deletions
diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index 9222492d7..d5564ec95 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -87,6 +87,11 @@ func (self *BranchesController) GetKeybindings(opts types.KeybindingsOpts) []*ty Description: self.c.Tr.FastForward, }, { + Key: opts.GetKey(opts.Config.Branches.CreateTag), + Handler: self.checkSelected(self.createTag), + Description: self.c.Tr.LcCreateTag, + }, + { Key: opts.GetKey(opts.Config.Commits.ViewResetOptions), Handler: self.checkSelected(self.createResetMenu), Description: self.c.Tr.LcViewResetOptions, @@ -363,6 +368,10 @@ func (self *BranchesController) fastForward(branch *models.Branch) error { }) } +func (self *BranchesController) createTag(branch *models.Branch) error { + return self.helpers.Tags.CreateTagMenu(branch.FullRefName(), func() {}) +} + func (self *BranchesController) createResetMenu(selectedBranch *models.Branch) error { return self.helpers.Refs.CreateGitResetMenu(selectedBranch.Name) } diff --git a/pkg/gui/controllers/helpers/tags_helper.go b/pkg/gui/controllers/helpers/tags_helper.go index 4683ffd0d..a2f2e9c77 100644 --- a/pkg/gui/controllers/helpers/tags_helper.go +++ b/pkg/gui/controllers/helpers/tags_helper.go @@ -21,20 +21,20 @@ func NewTagsHelper(c *types.HelperCommon, git *commands.GitCommand) *TagsHelper } } -func (self *TagsHelper) CreateTagMenu(commitSha string, onCreate func()) error { +func (self *TagsHelper) CreateTagMenu(ref string, onCreate func()) error { return self.c.Menu(types.CreateMenuOptions{ Title: self.c.Tr.TagMenuTitle, Items: []*types.MenuItem{ { Label: self.c.Tr.LcLightweightTag, OnPress: func() error { - return self.handleCreateLightweightTag(commitSha, onCreate) + return self.handleCreateLightweightTag(ref, onCreate) }, }, { Label: self.c.Tr.LcAnnotatedTag, OnPress: func() error { - return self.handleCreateAnnotatedTag(commitSha, onCreate) + return self.handleCreateAnnotatedTag(ref, onCreate) }, }, }, @@ -48,7 +48,7 @@ func (self *TagsHelper) afterTagCreate(onCreate func()) error { }) } -func (self *TagsHelper) handleCreateAnnotatedTag(commitSha string, onCreate func()) error { +func (self *TagsHelper) handleCreateAnnotatedTag(ref string, onCreate func()) error { return self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.TagNameTitle, HandleConfirm: func(tagName string) error { @@ -56,7 +56,7 @@ func (self *TagsHelper) handleCreateAnnotatedTag(commitSha string, onCreate func Title: self.c.Tr.TagMessageTitle, HandleConfirm: func(msg string) error { self.c.LogAction(self.c.Tr.Actions.CreateAnnotatedTag) - if err := self.git.Tag.CreateAnnotated(tagName, commitSha, msg); err != nil { + if err := self.git.Tag.CreateAnnotated(tagName, ref, msg); err != nil { return self.c.Error(err) } return self.afterTagCreate(onCreate) @@ -66,12 +66,12 @@ func (self *TagsHelper) handleCreateAnnotatedTag(commitSha string, onCreate func }) } -func (self *TagsHelper) handleCreateLightweightTag(commitSha string, onCreate func()) error { +func (self *TagsHelper) handleCreateLightweightTag(ref string, onCreate func()) error { return self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.TagNameTitle, HandleConfirm: func(tagName string) error { self.c.LogAction(self.c.Tr.Actions.CreateLightweightTag) - if err := self.git.Tag.CreateLightweight(tagName, commitSha); err != nil { + if err := self.git.Tag.CreateLightweight(tagName, ref); err != nil { return self.c.Error(err) } return self.afterTagCreate(onCreate) |