summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-01-01 13:57:49 +1100
committerGitHub <noreply@github.com>2023-01-01 13:57:49 +1100
commit1bb138c79c466e6207ae450a1bbd937c2713e449 (patch)
treee9af8b7851dc842228de65b6fb88e724a32fe3e7 /pkg/commands
parentc8fc1c3f5a58c2c494f06a2776cd99913aee0d78 (diff)
parentd98130c3efb814a40d576354329440a92faf7091 (diff)
Merge pull request #2341 from knutwalker/commit-verbose
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git_commands/commit.go10
-rw-r--r--pkg/commands/git_commands/commit_test.go15
2 files changed, 24 insertions, 1 deletions
diff --git a/pkg/commands/git_commands/commit.go b/pkg/commands/git_commands/commit.go
index 444ec17ac..be06cb245 100644
--- a/pkg/commands/git_commands/commit.go
+++ b/pkg/commands/git_commands/commit.go
@@ -62,7 +62,7 @@ func (self *CommitCommands) CommitCmdObj(message string) oscommands.ICmdObj {
// runs git commit without the -m argument meaning it will invoke the user's editor
func (self *CommitCommands) CommitEditorCmdObj() oscommands.ICmdObj {
- return self.cmd.New(fmt.Sprintf("git commit%s", self.signoffFlag()))
+ return self.cmd.New(fmt.Sprintf("git commit%s%s", self.signoffFlag(), self.verboseFlag()))
}
func (self *CommitCommands) signoffFlag() string {
@@ -73,6 +73,14 @@ func (self *CommitCommands) signoffFlag() string {
}
}
+func (self *CommitCommands) verboseFlag() string {
+ if self.UserConfig.Git.Commit.Verbose {
+ return " --verbose"
+ } else {
+ return ""
+ }
+}
+
// Get the subject of the HEAD commit
func (self *CommitCommands) GetHeadCommitMessage() (string, error) {
message, err := self.cmd.New("git log -1 --pretty=%s").DontLog().RunWithOutput()
diff --git a/pkg/commands/git_commands/commit_test.go b/pkg/commands/git_commands/commit_test.go
index 96a46ecf4..f44d350f9 100644
--- a/pkg/commands/git_commands/commit_test.go
+++ b/pkg/commands/git_commands/commit_test.go
@@ -32,6 +32,7 @@ func TestCommitCommitObj(t *testing.T) {
testName string
message string
configSignoff bool
+ configVerbose bool
configSkipHookPrefix string
expected string
}
@@ -41,6 +42,7 @@ func TestCommitCommitObj(t *testing.T) {
testName: "Commit",
message: "test",
configSignoff: false,
+ configVerbose: false,
configSkipHookPrefix: "",
expected: `git commit -m "test"`,
},
@@ -48,6 +50,7 @@ func TestCommitCommitObj(t *testing.T) {
testName: "Commit with --no-verify flag",
message: "WIP: test",
configSignoff: false,
+ configVerbose: false,
configSkipHookPrefix: "WIP",
expected: `git commit --no-verify -m "WIP: test"`,
},
@@ -55,6 +58,7 @@ func TestCommitCommitObj(t *testing.T) {
testName: "Commit with multiline message",
message: "line1\nline2",
configSignoff: false,
+ configVerbose: false,
configSkipHookPrefix: "",
expected: `git commit -m "line1" -m "line2"`,
},
@@ -62,13 +66,23 @@ func TestCommitCommitObj(t *testing.T) {
testName: "Commit with signoff",
message: "test",
configSignoff: true,
+ configVerbose: false,
configSkipHookPrefix: "",
expected: `git commit --signoff -m "test"`,
},
{
+ testName: "Commit with message ignores verbose flag",
+ message: "test",
+ configSignoff: false,
+ configVerbose: true,
+ configSkipHookPrefix: "",
+ expected: `git commit -m "test"`,
+ },
+ {
testName: "Commit with signoff and no-verify",
message: "WIP: test",
configSignoff: true,
+ configVerbose: false,
configSkipHookPrefix: "WIP",
expected: `git commit --no-verify --signoff -m "WIP: test"`,
},
@@ -79,6 +93,7 @@ func TestCommitCommitObj(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
userConfig.Git.SkipHookPrefix = s.configSkipHookPrefix
instance := buildCommitCommands(commonDeps{userConfig: userConfig})