diff options
author | mjarkk <mkopenga@gmail.com> | 2018-12-02 14:58:18 +0100 |
---|---|---|
committer | mjarkk <mkopenga@gmail.com> | 2018-12-02 14:58:18 +0100 |
commit | 2edd2b74ff68d6f55172c728e9d5f0d2aea69684 (patch) | |
tree | c99aadba94b9a30ffe8127c3f8622cf95f4b7f88 /pkg/gui/gui.go | |
parent | d91493b5876aeb644dab18b4c41b0ae56fb2f94b (diff) |
Removed a lot of useless code
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r-- | pkg/gui/gui.go | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 69343a95d..872a00c37 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -11,7 +11,6 @@ import ( "os" "os/exec" "strings" - "sync" "time" // "strings" @@ -351,50 +350,21 @@ func (gui *Gui) promptAnonymousReporting() error { }) } -func (gui *Gui) fetch(g *gocui.Gui) error { +func (gui *Gui) fetch(g *gocui.Gui, canSskForCredentials bool) error { err := gui.GitCommand.Fetch(func(passOrUname string) string { - if !gui.GitCommand.SavedCredentials.HasAsked { - var wg sync.WaitGroup - wg.Add(1) - gui.GitCommand.SavedCredentials.HasAsked = true - close := func(g *gocui.Gui, v *gocui.View) error { - wg.Done() - return nil - } - _ = gui.createConfirmationPanel( - g, - g.CurrentView(), - gui.Tr.SLocalize("RepoRequiresCredentialsTitle"), - gui.Tr.SLocalize("RepoRequiresCredentialsBody"), - close, - close, - ) - wg.Wait() - } return gui.waitForPassUname(gui.g, gui.g.CurrentView(), passOrUname) - }, false) + }, canSskForCredentials) - var reTryErr error - if err != nil && strings.Contains(err.Error(), "exit status 128") { - var wg sync.WaitGroup - wg.Add(1) - - currentView := g.CurrentView() + if canSskForCredentials && err != nil && strings.Contains(err.Error(), "exit status 128") { colorFunction := color.New(color.FgRed).SprintFunc() coloredMessage := colorFunction(strings.TrimSpace(gui.Tr.SLocalize("PassUnameWrong"))) close := func(g *gocui.Gui, v *gocui.View) error { - wg.Done() return nil } - _ = gui.createConfirmationPanel(g, currentView, gui.Tr.SLocalize("Error"), coloredMessage, close, close) - wg.Wait() - reTryErr = gui.fetch(g) + _ = gui.createConfirmationPanel(g, g.CurrentView(), gui.Tr.SLocalize("Error"), coloredMessage, close, close) } gui.refreshStatus(g) - if reTryErr != nil { - return reTryErr - } return err } @@ -451,9 +421,12 @@ func (gui *Gui) Run() error { } go func() { - err := gui.fetch(g) - if err == nil { - gui.goEvery(g, time.Second*60, gui.fetch) + time.Sleep(time.Second * 60) + err := gui.fetch(g, false) + if err == nil || !strings.Contains(err.Error(), "exit status 128") { + gui.goEvery(g, time.Second*60, func(g *gocui.Gui) error { + return gui.fetch(g, false) + }) } }() gui.goEvery(g, time.Second*10, gui.refreshFiles) |