mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-10 04:07:18 +02:00
show tag menu for creation on tags tab
This commit is contained in:
parent
b1d6ccddfb
commit
3e58797096
@ -9,7 +9,7 @@ func (c *GitCommand) CreateLightweightTag(tagName string, commitSha string) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *GitCommand) CreateAnnotatedTag(tagName, commitSha, msg string) error {
|
func (c *GitCommand) CreateAnnotatedTag(tagName, commitSha, msg string) error {
|
||||||
return c.RunCommand("git tag %s %s -m '%s'", tagName, commitSha, msg)
|
return c.RunCommand("git tag %s %s -m %s", tagName, commitSha, c.OSCommand.Quote(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *GitCommand) DeleteTag(tagName string) error {
|
func (c *GitCommand) DeleteTag(tagName string) error {
|
||||||
|
@ -584,29 +584,52 @@ func (gui *Gui) handleTagCommit() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return gui.createTagMenu(commit.Sha)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) createTagMenu(commitSha string) error {
|
||||||
items := []*menuItem{
|
items := []*menuItem{
|
||||||
{displayString: gui.Tr.LightweightTag, onPress: func() error {
|
{
|
||||||
return gui.handleCreateLightweightTag(commit.Sha)
|
displayString: gui.Tr.LightweightTag,
|
||||||
}},
|
onPress: func() error {
|
||||||
{displayString: gui.Tr.AnnotatedTag, onPress: func() error {
|
return gui.handleCreateLightweightTag(commitSha)
|
||||||
return gui.handleCreateAnnotatedTag(commit.Sha)
|
}},
|
||||||
}},
|
{
|
||||||
|
displayString: gui.Tr.AnnotatedTag,
|
||||||
|
onPress: func() error {
|
||||||
|
return gui.handleCreateAnnotatedTag(commitSha)
|
||||||
|
}},
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.createMenu(gui.Tr.TagMenuTitle, items, createMenuOptions{showCancel: false})
|
return gui.createMenu(gui.Tr.TagMenuTitle, items, createMenuOptions{showCancel: false})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) afterTagCreate(tagName string) error {
|
||||||
|
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS, TAGS}, then: func() {
|
||||||
|
// find the index of the tag and set that as the currently selected line
|
||||||
|
for i, tag := range gui.State.Tags {
|
||||||
|
if tag.Name == tagName {
|
||||||
|
gui.State.Panels.Tags.SelectedLineIdx = i
|
||||||
|
if err := gui.State.Contexts.Tags.HandleRender(); err != nil {
|
||||||
|
gui.Log.Error(err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}})
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleCreateAnnotatedTag(commitSha string) error {
|
func (gui *Gui) handleCreateAnnotatedTag(commitSha string) error {
|
||||||
return gui.prompt(promptOpts{
|
return gui.prompt(promptOpts{
|
||||||
title: gui.Tr.TagNameTitle,
|
title: gui.Tr.TagNameTitle,
|
||||||
handleConfirm: func(tagname string) error {
|
handleConfirm: func(tagName string) error {
|
||||||
return gui.prompt(promptOpts{
|
return gui.prompt(promptOpts{
|
||||||
title: gui.Tr.TagMessageTitle,
|
title: gui.Tr.TagMessageTitle,
|
||||||
handleConfirm: func(msg string) error {
|
handleConfirm: func(msg string) error {
|
||||||
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.CreateAnnotatedTag).CreateAnnotatedTag(tagname, commitSha, msg); err != nil {
|
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.CreateAnnotatedTag).CreateAnnotatedTag(tagName, commitSha, msg); err != nil {
|
||||||
return gui.surfaceError(err)
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS, TAGS}})
|
return gui.afterTagCreate(tagName)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -616,11 +639,11 @@ func (gui *Gui) handleCreateAnnotatedTag(commitSha string) error {
|
|||||||
func (gui *Gui) handleCreateLightweightTag(commitSha string) error {
|
func (gui *Gui) handleCreateLightweightTag(commitSha string) error {
|
||||||
return gui.prompt(promptOpts{
|
return gui.prompt(promptOpts{
|
||||||
title: gui.Tr.TagNameTitle,
|
title: gui.Tr.TagNameTitle,
|
||||||
handleConfirm: func(response string) error {
|
handleConfirm: func(tagName string) error {
|
||||||
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.CreateLightweightTag).CreateLightweightTag(response, commitSha); err != nil {
|
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.CreateLightweightTag).CreateLightweightTag(tagName, commitSha); err != nil {
|
||||||
return gui.surfaceError(err)
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []RefreshableView{COMMITS, TAGS}})
|
return gui.afterTagCreate(tagName)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -15,29 +15,8 @@ func (gui *Gui) getSelectedTag() *models.Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleCreateTag() error {
|
func (gui *Gui) handleCreateTag() error {
|
||||||
return gui.prompt(promptOpts{
|
// leaving commit SHA blank so that we're just creating the tag for the current commit
|
||||||
title: gui.Tr.CreateTagTitle,
|
return gui.createTagMenu("")
|
||||||
handleConfirm: func(tagName string) error {
|
|
||||||
// leaving commit SHA blank so that we're just creating the tag for the current commit
|
|
||||||
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.CreateLightweightTag).CreateLightweightTag(tagName, ""); err != nil {
|
|
||||||
return gui.surfaceError(err)
|
|
||||||
}
|
|
||||||
return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{COMMITS, TAGS}, then: func() {
|
|
||||||
// find the index of the tag and set that as the currently selected line
|
|
||||||
for i, tag := range gui.State.Tags {
|
|
||||||
if tag.Name == tagName {
|
|
||||||
gui.State.Panels.Tags.SelectedLineIdx = i
|
|
||||||
if err := gui.State.Contexts.Tags.HandleRender(); err != nil {
|
|
||||||
gui.Log.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) tagsRenderToMain() error {
|
func (gui *Gui) tagsRenderToMain() error {
|
||||||
|
Loading…
Reference in New Issue
Block a user