mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
feat(config): change git.commit.verbose
to accept "default"
This commit is contained in:
parent
1cf24a02d3
commit
965f7bfcb2
4 changed files with 66 additions and 22 deletions
|
@ -27,12 +27,11 @@ func TestCommitResetToCommit(t *testing.T) {
|
|||
runner.CheckForMissingCalls()
|
||||
}
|
||||
|
||||
func TestCommitCommitObj(t *testing.T) {
|
||||
func TestCommitCommitCmdObj(t *testing.T) {
|
||||
type scenario struct {
|
||||
testName string
|
||||
message string
|
||||
configSignoff bool
|
||||
configVerbose bool
|
||||
configSkipHookPrefix string
|
||||
expected string
|
||||
}
|
||||
|
@ -42,7 +41,6 @@ func TestCommitCommitObj(t *testing.T) {
|
|||
testName: "Commit",
|
||||
message: "test",
|
||||
configSignoff: false,
|
||||
configVerbose: false,
|
||||
configSkipHookPrefix: "",
|
||||
expected: `git commit -m "test"`,
|
||||
},
|
||||
|
@ -50,7 +48,6 @@ 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"`,
|
||||
},
|
||||
|
@ -58,7 +55,6 @@ 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"`,
|
||||
},
|
||||
|
@ -66,23 +62,13 @@ 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"`,
|
||||
},
|
||||
|
@ -93,7 +79,6 @@ 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})
|
||||
|
@ -104,6 +89,62 @@ func TestCommitCommitObj(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCommitCommitEditorCmdObj(t *testing.T) {
|
||||
type scenario struct {
|
||||
testName string
|
||||
configSignoff bool
|
||||
configVerbose string
|
||||
expected string
|
||||
}
|
||||
|
||||
scenarios := []scenario{
|
||||
{
|
||||
testName: "Commit using editor",
|
||||
configSignoff: false,
|
||||
configVerbose: "default",
|
||||
expected: `git commit`,
|
||||
},
|
||||
{
|
||||
testName: "Commit with --no-verbose flag",
|
||||
configSignoff: false,
|
||||
configVerbose: "never",
|
||||
expected: `git commit --no-verbose`,
|
||||
},
|
||||
{
|
||||
testName: "Commit with --verbose flag",
|
||||
configSignoff: false,
|
||||
configVerbose: "always",
|
||||
expected: `git commit --verbose`,
|
||||
},
|
||||
{
|
||||
testName: "Commit with --signoff",
|
||||
configSignoff: true,
|
||||
configVerbose: "default",
|
||||
expected: `git commit --signoff`,
|
||||
},
|
||||
{
|
||||
testName: "Commit with --signoff and --no-verbose",
|
||||
configSignoff: true,
|
||||
configVerbose: "never",
|
||||
expected: `git commit --signoff --no-verbose`,
|
||||
},
|
||||
}
|
||||
|
||||
for _, s := range scenarios {
|
||||
s := s
|
||||
t.Run(s.testName, func(t *testing.T) {
|
||||
userConfig := config.GetDefaultConfig()
|
||||
userConfig.Git.Commit.SignOff = s.configSignoff
|
||||
userConfig.Git.Commit.Verbose = s.configVerbose
|
||||
|
||||
instance := buildCommitCommands(commonDeps{userConfig: userConfig})
|
||||
|
||||
cmdStr := instance.CommitEditorCmdObj().ToString()
|
||||
assert.Equal(t, s.expected, cmdStr)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommitCreateFixupCommit(t *testing.T) {
|
||||
type scenario struct {
|
||||
testName string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue