From 80c6e0a8c422d25f1ef7364999645ac6c718bb9e Mon Sep 17 00:00:00 2001 From: mjarkk Date: Sat, 10 Nov 2018 17:02:39 +0100 Subject: [PATCH] Fixed pushing forever --- pkg/commands/exec_live_default.go | 9 ++++++--- pkg/commands/os.go | 3 +-- pkg/gui/confirmation_panel.go | 11 ++--------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/pkg/commands/exec_live_default.go b/pkg/commands/exec_live_default.go index 685974a1b..b0685b639 100644 --- a/pkg/commands/exec_live_default.go +++ b/pkg/commands/exec_live_default.go @@ -46,11 +46,10 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s go func() { scanner := bufio.NewScanner(tty) scanner.Split(scanWordsWithNewLines) - loop: for scanner.Scan() { select { case <-stopAsking: - break loop + // just do nothing default: toOutput := strings.Trim(scanner.Text(), " ") cmdOutput = append(cmdOutput, toOutput) @@ -63,8 +62,12 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s waitForBufio.Done() }() - if err = cmd.Wait(); err != nil { + err = cmd.Wait() + go func() { stopAsking <- struct{}{} + }() + <-stopAsking + if err != nil { waitForBufio.Wait() return strings.Join(cmdOutput, " "), err } diff --git a/pkg/commands/os.go b/pkg/commands/os.go index 7f2ddde25..b1f17c85f 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -77,8 +77,7 @@ func (c *OSCommand) DetectUnamePass(command string, ask func(string) string) err } for prompt, pattern := range prompts { - match, _ := regexp.MatchString(pattern, ttyText) - if match { + if match, _ := regexp.MatchString(pattern, ttyText); match { ttyText = "" return ask(prompt) } diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index ed0b0455a..0961370b8 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -7,7 +7,6 @@ package gui import ( - "log" "strings" "github.com/fatih/color" @@ -85,14 +84,8 @@ func (gui *Gui) prepareConfirmationPanel(currentView *gocui.View, title, prompt } func (gui *Gui) onNewPopupPanel() { - _, err := gui.g.SetViewOnBottom("commitMessage") - if err != nil { - log.Fatal(err) - } - _, err = gui.g.SetViewOnBottom("pushPassUname") - if err != nil { - log.Fatal(err) - } + _, _ = gui.g.SetViewOnBottom("commitMessage") + _, _ = gui.g.SetViewOnBottom("pushPassUname") } func (gui *Gui) createConfirmationPanel(g *gocui.Gui, currentView *gocui.View, title, prompt string, handleConfirm, handleClose func(*gocui.Gui, *gocui.View) error) error {