1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-17 21:18:31 +02:00

Read pull mode from git configuration

This commit is contained in:
Emiliano Ruiz Carletti 2021-04-12 23:56:25 -03:00 committed by Jesse Duffield
parent 0aad68acf0
commit d7865b3882

View File

@ -1,5 +1,9 @@
package config
import (
"github.com/jesseduffield/lazygit/pkg/secureexec"
)
type UserConfig struct {
Gui GuiConfig `yaml:"gui"`
Git GitConfig `yaml:"git"`
@ -323,7 +327,7 @@ func GetDefaultConfig() *UserConfig {
Args: "",
},
Pull: PullConfig{
Mode: "merge",
Mode: getPullModeFromGitConfig(),
},
SkipHookPrefix: "WIP",
AutoFetch: true,
@ -485,3 +489,17 @@ func GetDefaultConfig() *UserConfig {
NotARepository: "prompt",
}
}
func getPullModeFromGitConfig() string {
rebaseOut, rebaseErr := secureexec.Command("git config --get pull.rebase").Output()
if rebaseErr == nil && rebaseOut[0] == 't' {
return "rebase"
}
ffOut, ffErr := secureexec.Command("git config --get pull.ff").Output()
if ffErr == nil && ffOut[0] == 't' {
return "ff-only"
}
return "merge"
}