From 517b7d02839ab87693f19ea571b8bd29f07fd00e Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 28 Mar 2020 12:52:45 +1100 Subject: fix up some things with the patch handling stuff --- pkg/commands/git.go | 5 ++++- pkg/gui/branches_panel.go | 2 ++ pkg/gui/commit_files_panel.go | 4 +++- pkg/gui/confirmation_panel.go | 10 +++++----- pkg/gui/rebase_options_panel.go | 3 +++ 5 files changed, 17 insertions(+), 7 deletions(-) (limited to 'pkg') diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 19fe9c219..eb765f4fa 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -661,7 +661,10 @@ func (c *GitCommand) GenericMerge(commandType string, command string) error { ), ) if err != nil { - return err + if !strings.Contains(err.Error(), "no rebase in progress") { + return err + } + c.Log.Warn(err) } // sometimes we need to do a sequence of things in a rebase but the user needs to diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 72eab93f0..9f3bd0f97 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -351,11 +351,13 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error { if gui.State.Panels.Branches.SelectedLine == 0 { if err := gui.GitCommand.PullWithoutPasswordCheck("--ff-only"); err != nil { _ = gui.surfaceError(err) + return } _ = gui.refreshSidePanels(refreshOptions{mode: ASYNC}) } else { if err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName); err != nil { _ = gui.surfaceError(err) + return } _ = gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{BRANCHES}}) } diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 7431bf464..810a732ec 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -209,7 +209,9 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error { return gui.createConfirmationPanel(gui.g, gui.getCommitFilesView(), false, gui.Tr.SLocalize("DiscardPatch"), gui.Tr.SLocalize("DiscardPatchConfirm"), func(g *gocui.Gui, v *gocui.View) error { gui.GitCommand.PatchManager.Reset() return enterTheFile(selectedLineIdx) - }, nil) + }, func(g *gocui.Gui, v *gocui.View) error { + return gui.switchFocus(gui.g, nil, gui.getCommitFilesView()) + }) } return enterTheFile(selectedLineIdx) diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index 815d5a0f9..8aec1b6a8 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -127,11 +127,7 @@ func (gui *Gui) createPopupPanel(g *gocui.Gui, currentView *gocui.View, title, p } gui.renderString(g, "confirmation", prompt) - if err := gui.setKeyBindings(g, handleConfirm, handleClose, returnFocusOnClose); err != nil { - return err - } - - return gui.refreshSidePanels(refreshOptions{}) + return gui.setKeyBindings(g, handleConfirm, handleClose, returnFocusOnClose) }) return nil } @@ -183,6 +179,10 @@ func (gui *Gui) createSpecificErrorPanel(message string, nextView *gocui.View, w colorFunction := color.New(color.FgRed).SprintFunc() coloredMessage := colorFunction(strings.TrimSpace(message)) + if err := gui.refreshSidePanels(refreshOptions{mode: ASYNC}); err != nil { + return err + } + return gui.createConfirmationPanel(gui.g, nextView, true, gui.Tr.SLocalize("Error"), coloredMessage, nil, nil) } diff --git a/pkg/gui/rebase_options_panel.go b/pkg/gui/rebase_options_panel.go index 233f77e64..d34733591 100644 --- a/pkg/gui/rebase_options_panel.go +++ b/pkg/gui/rebase_options_panel.go @@ -74,6 +74,9 @@ func (gui *Gui) handleGenericMergeCommandResult(result error) error { return gui.genericMergeCommand("skip") } else if strings.Contains(result.Error(), "The previous cherry-pick is now empty") { return gui.genericMergeCommand("continue") + } else if strings.Contains(result.Error(), "No rebase in progress?") { + // assume in this case that we're already done + return nil } else if strings.Contains(result.Error(), "When you have resolved this problem") || strings.Contains(result.Error(), "fix conflicts") || strings.Contains(result.Error(), "Resolve all conflicts manually") { return gui.createConfirmationPanel(gui.g, gui.getFilesView(), true, gui.Tr.SLocalize("FoundConflictsTitle"), gui.Tr.SLocalize("FoundConflicts"), func(g *gocui.Gui, v *gocui.View) error { -- cgit v1.2.3