summaryrefslogtreecommitdiffstats
path: root/pkg/gui/files_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-10-20 22:21:16 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-10-22 21:33:17 +1100
commit6388af70acda91bf1bdc9cba9f38dc810f49f9ca (patch)
tree1901eb73ccf719c04b99b933a0cc2182e6dd3a0c /pkg/gui/files_panel.go
parent5ee559b89660cb850040ce41fee242514a09ba8b (diff)
simplify pull logic
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r--pkg/gui/files_panel.go39
1 files changed, 12 insertions, 27 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 06452a358..41ac25fb8 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -678,9 +678,10 @@ func (gui *Gui) handlePullFiles() error {
}
type PullFilesOptions struct {
- RemoteName string
- BranchName string
- span string
+ RemoteName string
+ BranchName string
+ FastForwardOnly bool
+ span string
}
func (gui *Gui) pullFiles(opts PullFilesOptions) error {
@@ -688,46 +689,30 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error {
return err
}
- mode := &gui.Config.GetUserConfig().Git.Pull.Mode
- *mode = gui.GitCommand.GetPullMode(*mode)
-
// TODO: this doesn't look like a good idea. Why the goroutine?
- go utils.Safe(func() { _ = gui.pullWithMode(*mode, opts) })
+ go utils.Safe(func() { _ = gui.pullWithLock(opts) })
return nil
}
-func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
+func (gui *Gui) pullWithLock(opts PullFilesOptions) error {
gui.Mutexes.FetchMutex.Lock()
defer gui.Mutexes.FetchMutex.Unlock()
gitCommand := gui.GitCommand.WithSpan(opts.span)
- err := gitCommand.Fetch(
- commands.FetchOptions{
+ err := gitCommand.Pull(
+ commands.PullOptions{
PromptUserForCredential: gui.promptUserForCredential,
RemoteName: opts.RemoteName,
BranchName: opts.BranchName,
+ FastForwardOnly: opts.FastForwardOnly,
},
)
- gui.handleCredentialsPopup(err)
- if err != nil {
- return gui.refreshSidePanels(refreshOptions{mode: ASYNC})
- }
-
- switch mode {
- case "rebase":
- err := gitCommand.RebaseBranch("FETCH_HEAD")
- return gui.handleGenericMergeCommandResult(err)
- case "merge":
- err := gitCommand.Merge("FETCH_HEAD", commands.MergeOpts{})
- return gui.handleGenericMergeCommandResult(err)
- case "ff-only":
- err := gitCommand.Merge("FETCH_HEAD", commands.MergeOpts{FastForwardOnly: true})
- return gui.handleGenericMergeCommandResult(err)
- default:
- return gui.createErrorPanel(fmt.Sprintf("git pull mode '%s' unrecognised", mode))
+ if err == nil {
+ _ = gui.closeConfirmationPrompt(false)
}
+ return gui.handleGenericMergeCommandResult(err)
}
type pushOpts struct {