summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/helpers/tags_helper.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/gui/controllers/helpers/tags_helper.go')
-rw-r--r--pkg/gui/controllers/helpers/tags_helper.go29
1 files changed, 26 insertions, 3 deletions
diff --git a/pkg/gui/controllers/helpers/tags_helper.go b/pkg/gui/controllers/helpers/tags_helper.go
index 47f2115ce..51957355a 100644
--- a/pkg/gui/controllers/helpers/tags_helper.go
+++ b/pkg/gui/controllers/helpers/tags_helper.go
@@ -4,6 +4,7 @@ import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
+ "github.com/jesseduffield/lazygit/pkg/utils"
)
type TagsHelper struct {
@@ -19,16 +20,16 @@ func NewTagsHelper(c *HelperCommon, commitsHelper *CommitsHelper) *TagsHelper {
}
func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error {
- onConfirm := func(tagName string, description string) error {
+ doCreateTag := func(tagName string, description string, force bool) error {
return self.c.WithWaitingStatus(self.c.Tr.CreatingTag, func(gocui.Task) error {
if description != "" {
self.c.LogAction(self.c.Tr.Actions.CreateAnnotatedTag)
- if err := self.c.Git().Tag.CreateAnnotated(tagName, ref, description); err != nil {
+ if err := self.c.Git().Tag.CreateAnnotated(tagName, ref, description, force); err != nil {
return self.c.Error(err)
}
} else {
self.c.LogAction(self.c.Tr.Actions.CreateLightweightTag)
- if err := self.c.Git().Tag.CreateLightweight(tagName, ref); err != nil {
+ if err := self.c.Git().Tag.CreateLightweight(tagName, ref, force); err != nil {
return self.c.Error(err)
}
}
@@ -41,6 +42,28 @@ func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error {
})
}
+ onConfirm := func(tagName string, description string) error {
+ if self.c.Git().Tag.HasTag(tagName) {
+ prompt := utils.ResolvePlaceholderString(
+ self.c.Tr.ForceTagPrompt,
+ map[string]string{
+ "tagName": tagName,
+ "cancelKey": self.c.UserConfig.Keybinding.Universal.Return,
+ "confirmKey": self.c.UserConfig.Keybinding.Universal.Confirm,
+ },
+ )
+ return self.c.Confirm(types.ConfirmOpts{
+ Title: self.c.Tr.ForceTag,
+ Prompt: prompt,
+ HandleConfirm: func() error {
+ return doCreateTag(tagName, description, true)
+ },
+ })
+ } else {
+ return doCreateTag(tagName, description, false)
+ }
+ }
+
return self.commitsHelper.OpenCommitMessagePanel(
&OpenCommitMessagePanelOpts{
CommitIndex: context.NoCommitIndex,