Skip to content

Commit b02441c

Browse files
committed
Regression test for moving custom patch to new commit from last commit of a stacked branch
I almost broke this during the development of this branch, so add a test to guard against that. The point here is that the stack remains intact, i.e. the newly created commit is the last commit of the lower branch, and thus shows the "*".
1 parent 0c0f951 commit b02441c

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package patch_building
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var MoveToNewCommitInLastCommitOfStackedBranch = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Move a patch from a commit to a new commit, in the last commit of a branch in the middle of a stack",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
GitVersion: AtLeast("2.38.0"),
13+
SetupConfig: func(config *config.AppConfig) {
14+
config.GetAppState().GitLogShowGraph = "never"
15+
},
16+
SetupRepo: func(shell *Shell) {
17+
shell.
18+
EmptyCommit("commit 01").
19+
NewBranch("branch1").
20+
EmptyCommit("commit 02").
21+
CreateFileAndAdd("file1", "file1 content").
22+
CreateFileAndAdd("file2", "file2 content").
23+
Commit("commit 03").
24+
NewBranch("branch2").
25+
CreateNCommitsStartingAt(2, 4)
26+
27+
shell.SetConfig("rebase.updateRefs", "true")
28+
},
29+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
30+
t.Views().Commits().
31+
Focus().
32+
Lines(
33+
Contains("CI commit 05").IsSelected(),
34+
Contains("CI commit 04"),
35+
Contains("CI * commit 03"),
36+
Contains("CI commit 02"),
37+
Contains("CI commit 01"),
38+
).
39+
NavigateToLine(Contains("commit 03")).
40+
PressEnter()
41+
42+
t.Views().CommitFiles().
43+
IsFocused().
44+
Lines(
45+
Equals("▼ /").IsSelected(),
46+
Equals(" A file1"),
47+
Equals(" A file2"),
48+
).
49+
SelectNextItem().
50+
PressPrimaryAction().
51+
PressEscape()
52+
53+
t.Views().Information().Content(Contains("Building patch"))
54+
55+
t.Common().SelectPatchOption(Contains("Move patch into new commit"))
56+
57+
t.ExpectPopup().CommitMessagePanel().
58+
InitialText(Equals("")).
59+
Type("new commit").Confirm()
60+
61+
t.Views().Commits().
62+
IsFocused().
63+
Lines(
64+
Contains("CI commit 05"),
65+
Contains("CI commit 04"),
66+
Contains("CI * new commit").IsSelected(),
67+
Contains("CI commit 03"),
68+
Contains("CI commit 02"),
69+
Contains("CI commit 01"),
70+
)
71+
},
72+
})

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ var tests = []*components.IntegrationTest{
311311
patch_building.MoveToNewCommit,
312312
patch_building.MoveToNewCommitFromAddedFile,
313313
patch_building.MoveToNewCommitFromDeletedFile,
314+
patch_building.MoveToNewCommitInLastCommitOfStackedBranch,
314315
patch_building.MoveToNewCommitPartialHunk,
315316
patch_building.RemoveFromCommit,
316317
patch_building.RemovePartsOfAddedFile,

0 commit comments

Comments
 (0)