mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
config: rely on .gitconfig for verbose commit messages (#2664)
As discussed in https://github.com/jesseduffield/lazygit/pull/2599, it makes more sense to have the user specify whether they want verbose commits from their own git config, rather than lazygit config. This means that we can remove all the code (including test coverage) associated with the custom verbose flag, and lazygit will just inherit the .gitconfig settings automatically. --- Tested visually locally, as well as running the tests that all pass.
This commit is contained in:
commit
5cb82a49f8
4 changed files with 1 additions and 38 deletions
|
@ -77,7 +77,6 @@ git:
|
|||
useConfig: false
|
||||
commit:
|
||||
signOff: false
|
||||
verbose: default # one of 'default' | 'always' | 'never'
|
||||
merging:
|
||||
# only applicable to unix users
|
||||
manualCommit: false
|
||||
|
|
|
@ -95,7 +95,6 @@ func (self *CommitCommands) commitMessageArgs(message string) []string {
|
|||
func (self *CommitCommands) CommitEditorCmdObj() oscommands.ICmdObj {
|
||||
cmdArgs := NewGitCmd("commit").
|
||||
ArgIf(self.signoffFlag() != "", self.signoffFlag()).
|
||||
ArgIf(self.verboseFlag() != "", self.verboseFlag()).
|
||||
ToArgv()
|
||||
|
||||
return self.cmd.New(cmdArgs)
|
||||
|
@ -109,17 +108,6 @@ func (self *CommitCommands) signoffFlag() string {
|
|||
}
|
||||
}
|
||||
|
||||
func (self *CommitCommands) verboseFlag() string {
|
||||
switch self.config.UserConfig.Git.Commit.Verbose {
|
||||
case "always":
|
||||
return "--verbose"
|
||||
case "never":
|
||||
return "--no-verbose"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// Get the subject of the HEAD commit
|
||||
func (self *CommitCommands) GetHeadCommitMessage() (string, error) {
|
||||
cmdArgs := NewGitCmd("log").Arg("-1", "--pretty=%s").ToArgv()
|
||||
|
|
|
@ -114,7 +114,6 @@ func TestCommitCommitEditorCmdObj(t *testing.T) {
|
|||
type scenario struct {
|
||||
testName string
|
||||
configSignoff bool
|
||||
configVerbose string
|
||||
expected []string
|
||||
}
|
||||
|
||||
|
@ -122,33 +121,13 @@ func TestCommitCommitEditorCmdObj(t *testing.T) {
|
|||
{
|
||||
testName: "Commit using editor",
|
||||
configSignoff: false,
|
||||
configVerbose: "default",
|
||||
expected: []string{"commit"},
|
||||
},
|
||||
{
|
||||
testName: "Commit with --no-verbose flag",
|
||||
configSignoff: false,
|
||||
configVerbose: "never",
|
||||
expected: []string{"commit", "--no-verbose"},
|
||||
},
|
||||
{
|
||||
testName: "Commit with --verbose flag",
|
||||
configSignoff: false,
|
||||
configVerbose: "always",
|
||||
expected: []string{"commit", "--verbose"},
|
||||
},
|
||||
{
|
||||
testName: "Commit with --signoff",
|
||||
configSignoff: true,
|
||||
configVerbose: "default",
|
||||
expected: []string{"commit", "--signoff"},
|
||||
},
|
||||
{
|
||||
testName: "Commit with --signoff and --no-verbose",
|
||||
configSignoff: true,
|
||||
configVerbose: "never",
|
||||
expected: []string{"commit", "--signoff", "--no-verbose"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, s := range scenarios {
|
||||
|
@ -156,7 +135,6 @@ func TestCommitCommitEditorCmdObj(t *testing.T) {
|
|||
t.Run(s.testName, func(t *testing.T) {
|
||||
userConfig := config.GetDefaultConfig()
|
||||
userConfig.Git.Commit.SignOff = s.configSignoff
|
||||
userConfig.Git.Commit.Verbose = s.configVerbose
|
||||
|
||||
runner := oscommands.NewFakeRunner(t).ExpectGitArgs(s.expected, "", nil)
|
||||
instance := buildCommitCommands(commonDeps{userConfig: userConfig, runner: runner})
|
||||
|
|
|
@ -103,8 +103,7 @@ type PagingConfig struct {
|
|||
}
|
||||
|
||||
type CommitConfig struct {
|
||||
SignOff bool `yaml:"signOff"`
|
||||
Verbose string `yaml:"verbose"`
|
||||
SignOff bool `yaml:"signOff"`
|
||||
}
|
||||
|
||||
type MergingConfig struct {
|
||||
|
@ -450,7 +449,6 @@ func GetDefaultConfig() *UserConfig {
|
|||
},
|
||||
Commit: CommitConfig{
|
||||
SignOff: false,
|
||||
Verbose: "default",
|
||||
},
|
||||
Merging: MergingConfig{
|
||||
ManualCommit: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue