Skip to content

Commit 9b88052

Browse files
committed
Add test demonstrating problem with revert (or cherry-pick) during a rebase
This problem can't happen inside of lazygit itself right now, but this will change in the future. It will only happen when you stopped in an interactive rebase on an "edit" entry, and then you perform a revert or cherry-pick consisting of more than one commit; in this situation lazygit will show a conflict although there is none. This is not possible with lazygit yet, as we don't support range-select for reverting, and we don't use `git cherry-pick` for cherry-picking. Both will change in the future, so it's good to fix this bug.
1 parent 6b6d881 commit 9b88052

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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 RevertDuringRebaseWhenStoppedOnEdit = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Revert a series of commits while stopped in a rebase",
10+
ExtraCmdArgs: []string{},
11+
Skip: false,
12+
SetupConfig: func(cfg *config.AppConfig) {
13+
// TODO: use our revert UI once we support range-select for reverts
14+
cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
15+
{
16+
Key: "X",
17+
Context: "commits",
18+
Command: "git -c core.editor=: revert HEAD^ HEAD^^",
19+
},
20+
}
21+
},
22+
SetupRepo: func(shell *Shell) {
23+
shell.EmptyCommit("master commit")
24+
shell.NewBranch("branch")
25+
shell.CreateNCommits(4)
26+
},
27+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
28+
t.Views().Commits().
29+
Focus().
30+
Lines(
31+
Contains("commit 04").IsSelected(),
32+
Contains("commit 03"),
33+
Contains("commit 02"),
34+
Contains("commit 01"),
35+
Contains("master commit"),
36+
).
37+
NavigateToLine(Contains("commit 03")).
38+
Press(keys.Universal.Edit).
39+
Lines(
40+
Contains("pick").Contains("commit 04"),
41+
Contains("<-- YOU ARE HERE --- commit 03").IsSelected(),
42+
Contains("commit 02"),
43+
Contains("commit 01"),
44+
Contains("master commit"),
45+
).
46+
Press("X").
47+
Lines(
48+
/* EXPECTED:
49+
Contains("pick").Contains("commit 04"),
50+
Contains(`<-- YOU ARE HERE --- Revert "commit 01"`).IsSelected(),
51+
Contains(`Revert "commit 02"`),
52+
Contains("commit 03"),
53+
Contains("commit 02"),
54+
Contains("commit 01"),
55+
Contains("master commit"),
56+
ACTUAL: */
57+
Contains("pick").Contains("commit 04"),
58+
Contains("edit").Contains("<-- CONFLICT --- commit 03").IsSelected(),
59+
Contains(`Revert "commit 01"`),
60+
Contains(`Revert "commit 02"`),
61+
Contains("commit 03"),
62+
Contains("commit 02"),
63+
Contains("commit 01"),
64+
Contains("master commit"),
65+
)
66+
},
67+
})

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ var tests = []*components.IntegrationTest{
264264
interactive_rebase.QuickStartKeepSelectionRange,
265265
interactive_rebase.Rebase,
266266
interactive_rebase.RebaseWithCommitThatBecomesEmpty,
267+
interactive_rebase.RevertDuringRebaseWhenStoppedOnEdit,
267268
interactive_rebase.RevertMultipleCommitsInInteractiveRebase,
268269
interactive_rebase.RevertSingleCommitInInteractiveRebase,
269270
interactive_rebase.RewordCommitWithEditorAndFail,

0 commit comments

Comments
 (0)