summaryrefslogtreecommitdiffstats
path: root/pkg/gui/files_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-11-13 21:16:24 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-11-13 21:36:16 +1100
commitf43ba728e3206b354d8cb66470fa2a42300c01a8 (patch)
treeca07ae1218481cead322d027e30b1f7d5c29a478 /pkg/gui/files_panel.go
parentb6623625700e1267f6543fa43a9f0322723ca1e5 (diff)
prompt to set upstream when pulling on untracked branch
prompt to set upstream when pulling on untracked branch
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r--pkg/gui/files_panel.go31
1 files changed, 28 insertions, 3 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 034860115..56ca123b4 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -408,7 +408,31 @@ func (gui *Gui) catSelectedFile(g *gocui.Gui) (string, error) {
return cat, nil
}
-func (gui *Gui) pullFiles(g *gocui.Gui, v *gocui.View) error {
+func (gui *Gui) handlePullFiles(g *gocui.Gui, v *gocui.View) error {
+ // if we have no upstream branch we need to set that first
+ _, pullables := gui.GitCommand.GetCurrentBranchUpstreamDifferenceCount()
+ currentBranchName, err := gui.GitCommand.CurrentBranchName()
+ if err != nil {
+ return err
+ }
+ if pullables == "?" {
+ return gui.createPromptPanel(g, v, gui.Tr.SLocalize("EnterUpstream"), "origin/"+currentBranchName, func(g *gocui.Gui, v *gocui.View) error {
+ upstream := gui.trimmedContent(v)
+ if err := gui.GitCommand.SetUpstreamBranch(upstream); err != nil {
+ errorMessage := err.Error()
+ if strings.Contains(errorMessage, "does not exist") {
+ errorMessage = fmt.Sprintf("upstream branch %s not found.\nIf you expect it to exist, you should fetch (with 'f').\nOtherwise, you should push (with 'shift+P')", upstream)
+ }
+ return gui.createErrorPanel(gui.g, errorMessage)
+ }
+ return gui.pullFiles(v)
+ })
+ }
+
+ return gui.pullFiles(v)
+}
+
+func (gui *Gui) pullFiles(v *gocui.View) error {
if err := gui.createLoaderPanel(gui.g, v, gui.Tr.SLocalize("PullWait")); err != nil {
return err
}
@@ -417,10 +441,11 @@ func (gui *Gui) pullFiles(g *gocui.Gui, v *gocui.View) error {
unamePassOpend := false
err := gui.GitCommand.Pull(func(passOrUname string) string {
unamePassOpend = true
- return gui.waitForPassUname(g, v, passOrUname)
+ return gui.waitForPassUname(gui.g, v, passOrUname)
})
- gui.HandleCredentialsPopup(g, unamePassOpend, err)
+ gui.HandleCredentialsPopup(gui.g, unamePassOpend, err)
}()
+
return nil
}