diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-04-07 11:35:34 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-04-07 13:13:40 +1000 |
commit | 60e33f5d8c0751ddb75dfeca2fa0c92b85beed94 (patch) | |
tree | 1b8329d93e2516b3eb485613feb9108a8d260f28 /pkg/gui/commits_panel.go | |
parent | b422692746281ee0707e639b254c21fbeda73604 (diff) |
Allow for creating fixup! commits
Diffstat (limited to 'pkg/gui/commits_panel.go')
-rw-r--r-- | pkg/gui/commits_panel.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index cd7aa9530..98817bf59 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -515,3 +515,42 @@ func (gui *Gui) hasCommit(commits []*commands.Commit, target string) (int, bool) func (gui *Gui) unchooseCommit(commits []*commands.Commit, i int) []*commands.Commit { return append(commits[:i], commits[i+1:]...) } + +func (gui *Gui) handleCreateFixupCommit(g *gocui.Gui, v *gocui.View) error { + commit := gui.getSelectedCommit(g) + if commit == nil { + return nil + } + + return gui.createConfirmationPanel(g, v, gui.Tr.SLocalize("CreateFixupCommit"), gui.Tr.TemplateLocalize( + "SureCreateFixupCommit", + Teml{ + "commit": commit.Sha, + }, + ), func(g *gocui.Gui, v *gocui.View) error { + if err := gui.GitCommand.CreateFixupCommit(commit.Sha); err != nil { + return gui.createErrorPanel(g, err.Error()) + } + + return gui.refreshSidePanels(gui.g) + }, nil) +} + +func (gui *Gui) handleSquashAllAboveFixupCommits(g *gocui.Gui, v *gocui.View) error { + commit := gui.getSelectedCommit(g) + if commit == nil { + return nil + } + + return gui.createConfirmationPanel(g, v, gui.Tr.SLocalize("SquashAboveCommits"), gui.Tr.TemplateLocalize( + "SureSquashAboveCommits", + Teml{ + "commit": commit.Sha, + }, + ), func(g *gocui.Gui, v *gocui.View) error { + return gui.WithWaitingStatus(gui.Tr.SLocalize("SquashingStatus"), func() error { + err := gui.GitCommand.SquashAllAboveFixupCommits(commit.Sha) + return gui.handleGenericMergeCommandResult(err) + }) + }, nil) +} |