diff options
author | mjarkk <mkopenga@gmail.com> | 2018-11-02 09:54:54 +0100 |
---|---|---|
committer | mjarkk <mkopenga@gmail.com> | 2018-11-02 09:54:54 +0100 |
commit | 5470bb41211f149aebc6127119585ede927f5913 (patch) | |
tree | 02a489378fe1825b764a080037cb0fecd630caed /pkg/gui | |
parent | 0e53a26d6fd1674f86f9ca3352544eee2f1f3326 (diff) |
Added username password detect to git pull
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commit_message_panel.go | 1 | ||||
-rw-r--r-- | pkg/gui/files_panel.go | 41 |
2 files changed, 31 insertions, 11 deletions
diff --git a/pkg/gui/commit_message_panel.go b/pkg/gui/commit_message_panel.go index 3f2225a7b..13ff074bc 100644 --- a/pkg/gui/commit_message_panel.go +++ b/pkg/gui/commit_message_panel.go @@ -84,6 +84,7 @@ func (gui *Gui) waitForPassUname(g *gocui.Gui, currentView *gocui.View, passOrUn // wait for username/passwords input waitForGroup.Wait() + _ = gui.switchFocus(g, pushPassUnameView, currentView) return unamePassMessage } diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 5c957d217..cdd619425 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -341,31 +341,50 @@ func (gui *Gui) refreshFiles(g *gocui.Gui) error { } func (gui *Gui) pullFiles(g *gocui.Gui, v *gocui.View) error { - gui.createMessagePanel(g, v, "", gui.Tr.SLocalize("PullWait")) + if err := gui.createMessagePanel(gui.g, v, "", gui.Tr.SLocalize("PullWait")); err != nil { + return err + } go func() { - if err := gui.GitCommand.Pull(); err != nil { - gui.createErrorPanel(g, err.Error()) + unamePassOpend := false + err := gui.GitCommand.Pull(func(passOrUname string) string { + unamePassOpend = true + return gui.waitForPassUname(g, v, passOrUname) + }) + if unamePassOpend { + _, _ = g.SetViewOnBottom("pushPassUname") + _ = g.DeleteView("pushPassUname") + } + if err != nil { + errMessage := err.Error() + if errMessage == "exit status 128" { + errMessage = gui.Tr.SLocalize("PassUnameWrong") + } + gui.createErrorPanel(gui.g, errMessage) } else { - gui.closeConfirmationPrompt(g) - gui.refreshCommits(g) - gui.refreshStatus(g) + _ = gui.closeConfirmationPrompt(gui.g) + _ = gui.refreshCommits(gui.g) + _ = gui.refreshStatus(gui.g) } gui.refreshFiles(g) }() return nil } -func (gui *Gui) pushWithForceFlag(g *gocui.Gui, currentView *gocui.View, force bool) error { - if err := gui.createMessagePanel(gui.g, currentView, "", gui.Tr.SLocalize("PushWait")); err != nil { +func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool) error { + if err := gui.createMessagePanel(gui.g, v, "", gui.Tr.SLocalize("PushWait")); err != nil { return err } go func() { + unamePassOpend := false branchName := gui.State.Branches[0].Name err := gui.GitCommand.Push(branchName, force, func(passOrUname string) string { - return gui.waitForPassUname(g, currentView, passOrUname) + unamePassOpend = true + return gui.waitForPassUname(g, v, passOrUname) }) - _, _ = g.SetViewOnBottom("pushPassUname") - _ = g.DeleteView("pushPassUname") + if unamePassOpend { + _, _ = g.SetViewOnBottom("pushPassUname") + _ = g.DeleteView("pushPassUname") + } if err != nil { errMessage := err.Error() if errMessage == "exit status 128" { |