mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-15 11:56:37 +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:
parent
b662362570
commit
f43ba728e3
@ -1052,3 +1052,7 @@ func (c *GitCommand) BeginInteractiveRebaseForCommit(commits []*Commit, commitIn
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *GitCommand) SetUpstreamBranch(upstream string) error {
|
||||||
|
return c.OSCommand.RunCommand(fmt.Sprintf("git branch -u %s", upstream))
|
||||||
|
}
|
||||||
|
@ -405,7 +405,7 @@ func (gui *Gui) handleCommitPick(g *gocui.Gui, v *gocui.View) error {
|
|||||||
|
|
||||||
// at this point we aren't actually rebasing so we will interpret this as an
|
// at this point we aren't actually rebasing so we will interpret this as an
|
||||||
// attempt to pull. We might revoke this later after enabling configurable keybindings
|
// attempt to pull. We might revoke this later after enabling configurable keybindings
|
||||||
return gui.pullFiles(g, v)
|
return gui.handlePullFiles(g, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleCommitRevert(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handleCommitRevert(g *gocui.Gui, v *gocui.View) error {
|
||||||
|
@ -408,7 +408,31 @@ func (gui *Gui) catSelectedFile(g *gocui.Gui) (string, error) {
|
|||||||
return cat, nil
|
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 {
|
if err := gui.createLoaderPanel(gui.g, v, gui.Tr.SLocalize("PullWait")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -417,10 +441,11 @@ func (gui *Gui) pullFiles(g *gocui.Gui, v *gocui.View) error {
|
|||||||
unamePassOpend := false
|
unamePassOpend := false
|
||||||
err := gui.GitCommand.Pull(func(passOrUname string) string {
|
err := gui.GitCommand.Pull(func(passOrUname string) string {
|
||||||
unamePassOpend = true
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
ViewName: "",
|
ViewName: "",
|
||||||
Key: 'p',
|
Key: 'p',
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.pullFiles,
|
Handler: gui.handlePullFiles,
|
||||||
Description: gui.Tr.SLocalize("pull"),
|
Description: gui.Tr.SLocalize("pull"),
|
||||||
}, {
|
}, {
|
||||||
ViewName: "",
|
ViewName: "",
|
||||||
|
@ -837,6 +837,9 @@ func addEnglish(i18nObject *i18n.Bundle) error {
|
|||||||
}, &i18n.Message{
|
}, &i18n.Message{
|
||||||
ID: "EnterUpstream",
|
ID: "EnterUpstream",
|
||||||
Other: `Enter upstream as '<remote> <branchname>'`,
|
Other: `Enter upstream as '<remote> <branchname>'`,
|
||||||
|
}, &i18n.Message{
|
||||||
|
ID: "EnterUpstreamWithSlash",
|
||||||
|
Other: `Enter upstream as '<remote>/<branchname>'`,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user