From 96177373523f2fce6c34b5128c344afdf9be1b5a Mon Sep 17 00:00:00 2001 From: Scott Callaway Date: Tue, 23 May 2023 14:55:57 +0100 Subject: 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. --- docs/Config.md | 1 - pkg/commands/git_commands/commit.go | 12 ------------ pkg/commands/git_commands/commit_test.go | 22 ---------------------- pkg/config/user_config.go | 4 +--- 4 files changed, 1 insertion(+), 38 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index 08e82b5ab..04e19881d 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -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 diff --git a/pkg/commands/git_commands/commit.go b/pkg/commands/git_commands/commit.go index 811f2b22e..47490f039 100644 --- a/pkg/commands/git_commands/commit.go +++ b/pkg/commands/git_commands/commit.go @@ -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() diff --git a/pkg/commands/git_commands/commit_test.go b/pkg/commands/git_commands/commit_test.go index 54d4cbbd1..235a72465 100644 --- a/pkg/commands/git_commands/commit_test.go +++ b/pkg/commands/git_commands/commit_test.go @@ -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}) diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 5b7edc9e4..0ad6a316f 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -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, -- cgit v1.2.3