Skip to content

Commit 0141bbd

Browse files
committed
Add test for amending a merge commit
1 parent 4c7d363 commit 0141bbd

26 files changed

+78
-1
lines changed

pkg/integration/components/shell.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (s *Shell) Checkout(name string) *Shell {
6464
}
6565

6666
func (s *Shell) Merge(name string) *Shell {
67-
return s.RunCommand("git merge --commit " + name)
67+
return s.RunCommand("git merge --commit --no-ff " + name)
6868
}
6969

7070
func (s *Shell) GitAdd(path string) *Shell {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package interactive_rebase
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Amends a staged file to a merge commit.",
10+
ExtraCmdArgs: "",
11+
Skip: false,
12+
SetupConfig: func(config *config.AppConfig) {},
13+
SetupRepo: func(shell *Shell) {
14+
shell.
15+
NewBranch("development-branch").
16+
CreateFileAndAdd("initial-file", "content").
17+
Commit("initial commit").
18+
NewBranch("feature-branch"). // it's also checked out automatically
19+
CreateFileAndAdd("new-feature-file", "new content").
20+
Commit("new feature commit").
21+
CheckoutBranch("development-branch").
22+
Merge("feature-branch").
23+
CreateFileAndAdd("post-merge-file", "content")
24+
},
25+
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
26+
assert.CommitCount(3)
27+
28+
input.SwitchToCommitsWindow()
29+
assert.CurrentViewName("commits")
30+
31+
input.PressKeys(keys.Commits.AmendToCommit)
32+
input.PressKeys(keys.Universal.Return)
33+
34+
assert.MatchHeadCommitMessage(Contains("Merge"))
35+
assert.CommitCount(3)
36+
},
37+
})

pkg/integration/tests/tests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var tests = []*components.IntegrationTest{
2929
branch.Rebase,
3030
branch.RebaseAndDrop,
3131
interactive_rebase.One,
32+
interactive_rebase.AmendMerge,
3233
custom_commands.Basic,
3334
custom_commands.MultiplePrompts,
3435
custom_commands.MenuFromCommand,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
new feature commit

test/integration_new/interactive_rebase/amend_merge/expected/repo/.git_keep/FETCH_HEAD

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref: refs/heads/development-branch
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a69464e3729a09e3a526d4a2db209ee43e64ba1c
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[core]
2+
repositoryformatversion = 0
3+
filemode = true
4+
bare = false
5+
logallrefupdates = true
6+
[user]
7+
8+
name = CI
9+
[commit]
10+
gpgSign = false
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Unnamed repository; edit this file 'description' to name the repository.
Binary file not shown.

0 commit comments

Comments
 (0)