mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-20 05:19:24 +02:00
Read pull mode from gitconfig lazily
This commit is contained in:
parent
46e500dc28
commit
c57a0077d0
@ -323,7 +323,7 @@ func GetDefaultConfig() *UserConfig {
|
||||
Args: "",
|
||||
},
|
||||
Pull: PullConfig{
|
||||
Mode: "merge",
|
||||
Mode: "auto",
|
||||
},
|
||||
SkipHookPrefix: "WIP",
|
||||
AutoFetch: true,
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
@ -659,7 +660,7 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error {
|
||||
return err
|
||||
}
|
||||
|
||||
mode := gui.Config.GetUserConfig().Git.Pull.Mode
|
||||
mode := gui.getPullMode()
|
||||
|
||||
// TODO: this doesn't look like a good idea. Why the goroutine?
|
||||
go utils.Safe(func() { _ = gui.pullWithMode(mode, opts) })
|
||||
@ -667,6 +668,34 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gui *Gui) getPullMode() string {
|
||||
mode := &gui.Config.GetUserConfig().Git.Pull.Mode
|
||||
if *mode == "auto" {
|
||||
var isRebase bool
|
||||
var isFf bool
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
go func() {
|
||||
isRebase = gui.GitCommand.GetConfigValue("pull.rebase") == "true"
|
||||
wg.Done()
|
||||
}()
|
||||
go func() {
|
||||
isFf = gui.GitCommand.GetConfigValue("pull.ff") == "true"
|
||||
wg.Done()
|
||||
}()
|
||||
wg.Wait()
|
||||
|
||||
if isRebase {
|
||||
*mode = "rebase"
|
||||
} else if isFf {
|
||||
*mode = "ff-only"
|
||||
} else {
|
||||
*mode = "merge"
|
||||
}
|
||||
}
|
||||
return *mode
|
||||
}
|
||||
|
||||
func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error {
|
||||
gui.Mutexes.FetchMutex.Lock()
|
||||
defer gui.Mutexes.FetchMutex.Unlock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user