1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-09-16 09:16:26 +02:00

prompt to set upstream when pulling on untracked branch

prompt to set upstream when pulling on untracked branch
This commit is contained in:
Jesse Duffield
2019-11-13 21:16:24 +11:00
parent b662362570
commit f43ba728e3
5 changed files with 37 additions and 5 deletions

View File

@@ -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
}