1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-06 03:53:59 +02:00

support creating annotated tags

This commit is contained in:
Francisco Miamoto 2021-09-11 19:19:25 -03:00 committed by Jesse Duffield
parent 4df003cc44
commit b1d6ccddfb
3 changed files with 41 additions and 4 deletions

View File

@ -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))
}

View File

@ -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 {

View File

@ -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",