From cd4063c7630395ab91d8a47ee86025dda823f6e8 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen Date: Tue, 21 Aug 2018 08:54:51 -0400 Subject: [PATCH] s/escape/quit --- pkg/commands/git.go | 4 ++-- pkg/gui/files_panel.go | 23 ++++++++++++----------- pkg/gui/gui.go | 2 +- pkg/gui/keybindings.go | 6 +++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/pkg/commands/git.go b/pkg/commands/git.go index bf9aa6646..65e457b6f 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -270,12 +270,12 @@ func (c *GitCommand) Pull() error { } // Push push to a branch -func (c *GitCommand) Push(branchName string, force bool) error { +func (c *GitCommand) Push(branchName string, force bool) (*exec.Cmd, error) { forceFlag := "" if force { forceFlag = "--force-with-lease " } - return c.OSCommand.RunCommand("git push " + forceFlag + "-u origin " + branchName) + return c.OSCommand.PrepareSubProcess(c.OSCommand.Platform.shell, c.OSCommand.Platform.shellArg, "git push " + forceFlag + "-u origin " + branchName) } // SquashPreviousTwoCommits squashes a commit down to the one below it diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 5791a9d15..0b921ca0d 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -364,17 +364,18 @@ func (gui *Gui) pushWithForceFlag(currentView *gocui.View, force bool) error { if err := gui.createMessagePanel(gui.g, currentView, "", gui.Tr.SLocalize("PushWait")); err != nil { return err } - go func() { - branchName := gui.State.Branches[0].Name - if err := gui.GitCommand.Push(branchName, force); err != nil { - _ = gui.createErrorPanel(gui.g, err.Error()) - } else { - _ = gui.closeConfirmationPrompt(gui.g) - _ = gui.refreshCommits(gui.g) - _ = gui.refreshStatus(gui.g) - } - }() - return nil + branchName := gui.State.Branches[0].Name + sub, err := gui.GitCommand.Push(branchName, force) + if err != nil { + _ = gui.createErrorPanel(gui.g, err.Error()) + } + if sub != nil { + gui.SubProcess = sub + return gui.Errors.ErrSubProcess + } + _ = gui.closeConfirmationPrompt(gui.g) + _ = gui.refreshStatus(gui.g) + return gui.refreshCommits(gui.g) } func (gui *Gui) pushFiles(g *gocui.Gui, v *gocui.View) error { diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index d07c7afee..66777b3a6 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -362,6 +362,6 @@ func (gui *Gui) RunWithSubprocesses() { } } -func (gui *Gui) escape(g *gocui.Gui, v *gocui.View) error { +func (gui *Gui) quit(g *gocui.Gui, v *gocui.View) error { return gocui.ErrQuit } diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index f0f2538b2..d09ed64b1 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -14,9 +14,9 @@ type Binding struct { func (gui *Gui) keybindings(g *gocui.Gui) error { bindings := []Binding{ - {ViewName: "", Key: 'q', Modifier: gocui.ModNone, Handler: gui.escape}, - {ViewName: "", Key: gocui.KeyCtrlC, Modifier: gocui.ModNone, Handler: gui.escape}, - {ViewName: "", Key: gocui.KeyEsc, Modifier: gocui.ModNone, Handler: gui.escape}, + {ViewName: "", Key: 'q', Modifier: gocui.ModNone, Handler: gui.quit}, + {ViewName: "", Key: gocui.KeyCtrlC, Modifier: gocui.ModNone, Handler: gui.quit}, + {ViewName: "", Key: gocui.KeyEsc, Modifier: gocui.ModNone, Handler: gui.quit}, {ViewName: "", Key: gocui.KeyPgup, Modifier: gocui.ModNone, Handler: gui.scrollUpMain}, {ViewName: "", Key: gocui.KeyPgdn, Modifier: gocui.ModNone, Handler: gui.scrollDownMain}, {ViewName: "", Key: gocui.KeyCtrlU, Modifier: gocui.ModNone, Handler: gui.scrollUpMain},