1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-23 12:18:51 +02:00

config: rely on .gitconfig for verbose commit messages

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.
This commit is contained in:
Scott Callaway 2023-05-23 14:55:57 +01:00 committed by Stefan Haller
parent a251f6ad6c
commit 9617737352
4 changed files with 1 additions and 38 deletions

View File

@ -77,7 +77,6 @@ git:
useConfig: false useConfig: false
commit: commit:
signOff: false signOff: false
verbose: default # one of 'default' | 'always' | 'never'
merging: merging:
# only applicable to unix users # only applicable to unix users
manualCommit: false manualCommit: false

View File

@ -95,7 +95,6 @@ func (self *CommitCommands) commitMessageArgs(message string) []string {
func (self *CommitCommands) CommitEditorCmdObj() oscommands.ICmdObj { func (self *CommitCommands) CommitEditorCmdObj() oscommands.ICmdObj {
cmdArgs := NewGitCmd("commit"). cmdArgs := NewGitCmd("commit").
ArgIf(self.signoffFlag() != "", self.signoffFlag()). ArgIf(self.signoffFlag() != "", self.signoffFlag()).
ArgIf(self.verboseFlag() != "", self.verboseFlag()).
ToArgv() ToArgv()
return self.cmd.New(cmdArgs) 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 // Get the subject of the HEAD commit
func (self *CommitCommands) GetHeadCommitMessage() (string, error) { func (self *CommitCommands) GetHeadCommitMessage() (string, error) {
cmdArgs := NewGitCmd("log").Arg("-1", "--pretty=%s").ToArgv() cmdArgs := NewGitCmd("log").Arg("-1", "--pretty=%s").ToArgv()

View File

@ -114,7 +114,6 @@ func TestCommitCommitEditorCmdObj(t *testing.T) {
type scenario struct { type scenario struct {
testName string testName string
configSignoff bool configSignoff bool
configVerbose string
expected []string expected []string
} }
@ -122,33 +121,13 @@ func TestCommitCommitEditorCmdObj(t *testing.T) {
{ {
testName: "Commit using editor", testName: "Commit using editor",
configSignoff: false, configSignoff: false,
configVerbose: "default",
expected: []string{"commit"}, 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", testName: "Commit with --signoff",
configSignoff: true, configSignoff: true,
configVerbose: "default",
expected: []string{"commit", "--signoff"}, 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 { for _, s := range scenarios {
@ -156,7 +135,6 @@ func TestCommitCommitEditorCmdObj(t *testing.T) {
t.Run(s.testName, func(t *testing.T) { t.Run(s.testName, func(t *testing.T) {
userConfig := config.GetDefaultConfig() userConfig := config.GetDefaultConfig()
userConfig.Git.Commit.SignOff = s.configSignoff userConfig.Git.Commit.SignOff = s.configSignoff
userConfig.Git.Commit.Verbose = s.configVerbose
runner := oscommands.NewFakeRunner(t).ExpectGitArgs(s.expected, "", nil) runner := oscommands.NewFakeRunner(t).ExpectGitArgs(s.expected, "", nil)
instance := buildCommitCommands(commonDeps{userConfig: userConfig, runner: runner}) instance := buildCommitCommands(commonDeps{userConfig: userConfig, runner: runner})

View File

@ -103,8 +103,7 @@ type PagingConfig struct {
} }
type CommitConfig struct { type CommitConfig struct {
SignOff bool `yaml:"signOff"` SignOff bool `yaml:"signOff"`
Verbose string `yaml:"verbose"`
} }
type MergingConfig struct { type MergingConfig struct {
@ -450,7 +449,6 @@ func GetDefaultConfig() *UserConfig {
}, },
Commit: CommitConfig{ Commit: CommitConfig{
SignOff: false, SignOff: false,
Verbose: "default",
}, },
Merging: MergingConfig{ Merging: MergingConfig{
ManualCommit: false, ManualCommit: false,