mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-21 00:30:00 +02:00
Read pull mode from git configuration
This commit is contained in:
@ -1,5 +1,9 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
||||||
|
)
|
||||||
|
|
||||||
type UserConfig struct {
|
type UserConfig struct {
|
||||||
Gui GuiConfig `yaml:"gui"`
|
Gui GuiConfig `yaml:"gui"`
|
||||||
Git GitConfig `yaml:"git"`
|
Git GitConfig `yaml:"git"`
|
||||||
@ -317,7 +321,7 @@ func GetDefaultConfig() *UserConfig {
|
|||||||
Args: "",
|
Args: "",
|
||||||
},
|
},
|
||||||
Pull: PullConfig{
|
Pull: PullConfig{
|
||||||
Mode: "merge",
|
Mode: getPullModeFromGitConfig(),
|
||||||
},
|
},
|
||||||
SkipHookPrefix: "WIP",
|
SkipHookPrefix: "WIP",
|
||||||
AutoFetch: true,
|
AutoFetch: true,
|
||||||
@ -478,3 +482,17 @@ func GetDefaultConfig() *UserConfig {
|
|||||||
NotARepository: "prompt",
|
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"
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user