From 3c1322914518168374be02a78cee968cf1d13730 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 18 Nov 2019 09:38:36 +1100 Subject: add tags panel --- pkg/gui/commits_panel.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'pkg/gui/commits_panel.go') diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index c29935f14..22ea6fe7e 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -584,3 +584,30 @@ func (gui *Gui) handleCreateCommitResetMenu(g *gocui.Gui, v *gocui.View) error { return gui.createMenu(fmt.Sprintf("%s %s", gui.Tr.SLocalize("resetTo"), commit.Sha), options, len(options), handleMenuPress) } + +func (gui *Gui) handleTagCommit(g *gocui.Gui, v *gocui.View) 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.getSelectedCommit(g) + if commit == nil { + return nil + } + + return gui.handleCreateLightweightTag(commit.Sha) +} + +func (gui *Gui) handleCreateLightweightTag(commitSha string) error { + return gui.createPromptPanel(gui.g, gui.getCommitsView(), gui.Tr.SLocalize("TagNameTitle"), "", func(g *gocui.Gui, v *gocui.View) error { + if err := gui.GitCommand.CreateLightweightTag(v.Buffer(), commitSha); err != nil { + return gui.createErrorPanel(g, err.Error()) + } + if err := gui.refreshCommits(g); err != nil { + return gui.createErrorPanel(g, err.Error()) + } + if err := gui.refreshTags(); err != nil { + return gui.createErrorPanel(g, err.Error()) + } + return gui.handleCommitSelect(g, v) + }) +} -- cgit v1.2.3