mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-23 22:24:51 +02:00
Support range selection for reverting commits
This commit is contained in:
@@ -9,16 +9,7 @@ var RevertWithConflictMultipleCommits = NewIntegrationTest(NewIntegrationTestArg
|
||||
Description: "Reverts a range of commits, the first of which conflicts",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
// TODO: use our revert UI once we support range-select for reverts
|
||||
cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
|
||||
{
|
||||
Key: "X",
|
||||
Context: "commits",
|
||||
Command: "git -c core.editor=: revert HEAD^ HEAD^^",
|
||||
},
|
||||
}
|
||||
},
|
||||
SetupConfig: func(cfg *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFileAndAdd("myfile", "")
|
||||
shell.Commit("add empty file")
|
||||
@@ -38,13 +29,18 @@ var RevertWithConflictMultipleCommits = NewIntegrationTest(NewIntegrationTestArg
|
||||
Contains("CI ◯ unrelated change"),
|
||||
Contains("CI ◯ add empty file"),
|
||||
).
|
||||
Press("X").
|
||||
SelectNextItem().
|
||||
Press(keys.Universal.RangeSelectDown).
|
||||
Press(keys.Commits.RevertCommit).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Alert().
|
||||
Title(Equals("Error")).
|
||||
// The exact error message is different on different git versions,
|
||||
// but they all contain the word 'conflict' somewhere.
|
||||
Content(Contains("conflict")).
|
||||
t.ExpectPopup().Confirmation().
|
||||
Title(Equals("Revert commit")).
|
||||
Content(Equals("Are you sure you want to revert the selected commits?")).
|
||||
Confirm()
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Conflicts!")).
|
||||
Select(Contains("View conflicts")).
|
||||
Confirm()
|
||||
}).
|
||||
Lines(
|
||||
@@ -59,7 +55,7 @@ var RevertWithConflictMultipleCommits = NewIntegrationTest(NewIntegrationTestArg
|
||||
t.Views().Options().Content(Contains("View revert options: m"))
|
||||
t.Views().Information().Content(Contains("Reverting (Reset)"))
|
||||
|
||||
t.Views().Files().Focus().
|
||||
t.Views().Files().IsFocused().
|
||||
Lines(
|
||||
Contains("UU myfile").IsSelected(),
|
||||
).
|
||||
|
||||
@@ -9,18 +9,10 @@ var RevertDuringRebaseWhenStoppedOnEdit = NewIntegrationTest(NewIntegrationTestA
|
||||
Description: "Revert a series of commits while stopped in a rebase",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
// TODO: use our revert UI once we support range-select for reverts
|
||||
cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
|
||||
{
|
||||
Key: "X",
|
||||
Context: "commits",
|
||||
Command: "git -c core.editor=: revert HEAD^ HEAD^^",
|
||||
},
|
||||
}
|
||||
},
|
||||
SetupConfig: func(cfg *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.EmptyCommit("master commit")
|
||||
shell.EmptyCommit("master commit 1")
|
||||
shell.EmptyCommit("master commit 2")
|
||||
shell.NewBranch("branch")
|
||||
shell.CreateNCommits(4)
|
||||
},
|
||||
@@ -32,7 +24,8 @@ var RevertDuringRebaseWhenStoppedOnEdit = NewIntegrationTest(NewIntegrationTestA
|
||||
Contains("commit 03"),
|
||||
Contains("commit 02"),
|
||||
Contains("commit 01"),
|
||||
Contains("master commit"),
|
||||
Contains("master commit 2"),
|
||||
Contains("master commit 1"),
|
||||
).
|
||||
NavigateToLine(Contains("commit 03")).
|
||||
Press(keys.Universal.Edit).
|
||||
@@ -41,17 +34,27 @@ var RevertDuringRebaseWhenStoppedOnEdit = NewIntegrationTest(NewIntegrationTestA
|
||||
Contains("<-- YOU ARE HERE --- commit 03").IsSelected(),
|
||||
Contains("commit 02"),
|
||||
Contains("commit 01"),
|
||||
Contains("master commit"),
|
||||
Contains("master commit 2"),
|
||||
Contains("master commit 1"),
|
||||
).
|
||||
Press("X").
|
||||
SelectNextItem().
|
||||
Press(keys.Universal.RangeSelectDown).
|
||||
Press(keys.Commits.RevertCommit).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Confirmation().
|
||||
Title(Equals("Revert commit")).
|
||||
Content(MatchesRegexp(`Are you sure you want to revert \w+?`)).
|
||||
Confirm()
|
||||
}).
|
||||
Lines(
|
||||
Contains("pick").Contains("commit 04"),
|
||||
Contains(`<-- YOU ARE HERE --- Revert "commit 01"`).IsSelected(),
|
||||
Contains(`<-- YOU ARE HERE --- Revert "commit 01"`),
|
||||
Contains(`Revert "commit 02"`),
|
||||
Contains("commit 03"),
|
||||
Contains("commit 02"),
|
||||
Contains("commit 01"),
|
||||
Contains("master commit"),
|
||||
Contains("commit 02").IsSelected(),
|
||||
Contains("commit 01").IsSelected(),
|
||||
Contains("master commit 2"),
|
||||
Contains("master commit 1"),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
||||
@@ -9,16 +9,7 @@ var RevertMultipleCommitsInInteractiveRebase = NewIntegrationTest(NewIntegration
|
||||
Description: "Reverts a range of commits, the first of which conflicts, in the middle of an interactive rebase",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(cfg *config.AppConfig) {
|
||||
// TODO: use our revert UI once we support range-select for reverts
|
||||
cfg.GetUserConfig().CustomCommands = []config.CustomCommand{
|
||||
{
|
||||
Key: "X",
|
||||
Context: "commits",
|
||||
Command: "git -c core.editor=: revert HEAD^ HEAD^^",
|
||||
},
|
||||
}
|
||||
},
|
||||
SetupConfig: func(cfg *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.CreateFileAndAdd("myfile", "")
|
||||
shell.Commit("add empty file")
|
||||
@@ -44,13 +35,18 @@ var RevertMultipleCommitsInInteractiveRebase = NewIntegrationTest(NewIntegration
|
||||
).
|
||||
NavigateToLine(Contains("add second line")).
|
||||
Press(keys.Universal.Edit).
|
||||
Press("X").
|
||||
SelectNextItem().
|
||||
Press(keys.Universal.RangeSelectDown).
|
||||
Press(keys.Commits.RevertCommit).
|
||||
Tap(func() {
|
||||
t.ExpectPopup().Alert().
|
||||
Title(Equals("Error")).
|
||||
// The exact error message is different on different git versions,
|
||||
// but they all contain the word 'conflict' somewhere.
|
||||
Content(Contains("conflict")).
|
||||
t.ExpectPopup().Confirmation().
|
||||
Title(Equals("Revert commit")).
|
||||
Content(Equals("Are you sure you want to revert the selected commits?")).
|
||||
Confirm()
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Conflicts!")).
|
||||
Select(Contains("View conflicts")).
|
||||
Confirm()
|
||||
}).
|
||||
Lines(
|
||||
@@ -67,7 +63,7 @@ var RevertMultipleCommitsInInteractiveRebase = NewIntegrationTest(NewIntegration
|
||||
t.Views().Options().Content(Contains("View revert options: m"))
|
||||
t.Views().Information().Content(Contains("Reverting (Reset)"))
|
||||
|
||||
t.Views().Files().Focus().
|
||||
t.Views().Files().IsFocused().
|
||||
Lines(
|
||||
Contains("UU myfile").IsSelected(),
|
||||
).
|
||||
|
||||
Reference in New Issue
Block a user