1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-23 00:39:13 +02:00

stop pulling in general

This commit is contained in:
Jesse Duffield
2020-08-11 21:38:59 +10:00
parent f49e4946f2
commit bea2ae5ff5
3 changed files with 32 additions and 44 deletions

View File

@ -510,16 +510,6 @@ func (c *GitCommand) AmendHead() (*exec.Cmd, error) {
return nil, c.OSCommand.RunCommand(command) return nil, c.OSCommand.RunCommand(command)
} }
// Pull pulls from repo
func (c *GitCommand) Pull(args string, promptUserForCredential func(string) string) error {
return c.OSCommand.DetectUnamePass("git pull --no-edit --rebase ", promptUserForCredential)
}
// PullWithoutPasswordCheck assumes that the pull will not prompt the user for a password
func (c *GitCommand) PullWithoutPasswordCheck(args string) error {
return c.OSCommand.RunCommand("git pull --no-edit " + args)
}
// Push pushes to a branch // Push pushes to a branch
func (c *GitCommand) Push(branchName string, force bool, upstream string, args string, promptUserForCredential func(string) string) error { func (c *GitCommand) Push(branchName string, force bool, upstream string, args string, promptUserForCredential func(string) string) error {
forceFlag := "" forceFlag := ""

View File

@ -399,11 +399,8 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error {
_ = gui.createLoaderPanel(gui.g, v, message) _ = gui.createLoaderPanel(gui.g, v, message)
if gui.State.Panels.Branches.SelectedLine == 0 { if gui.State.Panels.Branches.SelectedLine == 0 {
if err := gui.GitCommand.PullWithoutPasswordCheck("--ff-only"); err != nil { _ = gui.pullWithMode("ff-only", PullFilesOptions{})
_ = gui.surfaceError(err)
return return
}
_ = gui.refreshSidePanels(refreshOptions{mode: ASYNC})
} else { } else {
if err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName); err != nil { if err := gui.GitCommand.FastForward(branch.Name, remoteName, remoteBranchName); err != nil {
_ = gui.surfaceError(err) _ = gui.surfaceError(err)

View File

@ -476,9 +476,14 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error {
return err return err
} }
strategy := gui.Config.GetUserConfig().GetString("git.pull.mode") mode := gui.Config.GetUserConfig().GetString("git.pull.mode")
go func() { go gui.pullWithMode(mode, opts)
return nil
}
func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
err := gui.GitCommand.Fetch( err := gui.GitCommand.Fetch(
commands.FetchOptions{ commands.FetchOptions{
PromptUserForCredential: gui.promptUserForCredential, PromptUserForCredential: gui.promptUserForCredential,
@ -488,26 +493,22 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error {
) )
gui.HandleCredentialsPopup(err) gui.HandleCredentialsPopup(err)
if err != nil { if err != nil {
_ = gui.refreshSidePanels(refreshOptions{mode: ASYNC}) return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
return
} }
switch strategy { switch mode {
case "rebase": case "rebase":
err := gui.GitCommand.RebaseBranch("FETCH_HEAD") err := gui.GitCommand.RebaseBranch("FETCH_HEAD")
_ = gui.handleGenericMergeCommandResult(err) return gui.handleGenericMergeCommandResult(err)
case "merge": case "merge":
err := gui.GitCommand.Merge("FETCH_HEAD", commands.MergeOpts{}) err := gui.GitCommand.Merge("FETCH_HEAD", commands.MergeOpts{})
_ = gui.handleGenericMergeCommandResult(err) return gui.handleGenericMergeCommandResult(err)
case "ff-only": case "ff-only":
err := gui.GitCommand.Merge("FETCH_HEAD", commands.MergeOpts{FastForwardOnly: true}) err := gui.GitCommand.Merge("FETCH_HEAD", commands.MergeOpts{FastForwardOnly: true})
_ = gui.handleGenericMergeCommandResult(err) return gui.handleGenericMergeCommandResult(err)
default: default:
_ = gui.createErrorPanel(fmt.Sprintf("git pull strategy '%s' unrecognised", strategy)) return gui.createErrorPanel(fmt.Sprintf("git pull mode '%s' unrecognised", mode))
} }
}()
return nil
} }
func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool, upstream string, args string) error { func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool, upstream string, args string) error {