summaryrefslogtreecommitdiffstats
path: root/pkg/integration
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-06-11 08:08:55 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-07-31 08:41:41 +0200
commit66de981e9108c83ddb1d778eb92e948050c85311 (patch)
treefcc5c35ee5909cd71157c331ef10beb200fe05ee /pkg/integration
parent375451785c2f72da368e0cafaff9dc2e9f40a5b4 (diff)
Add a "Mark commit as base commit for rebase" command
This allows to do the equivalent of "git rebase --onto <target> <base>", by first marking the <base> commit with the new command, and then selecting the target branch and invoking the usual rebase command there.
Diffstat (limited to 'pkg/integration')
-rw-r--r--pkg/integration/tests/branch/rebase_from_marked_base.go78
-rw-r--r--pkg/integration/tests/test_list.go1
2 files changed, 79 insertions, 0 deletions
diff --git a/pkg/integration/tests/branch/rebase_from_marked_base.go b/pkg/integration/tests/branch/rebase_from_marked_base.go
new file mode 100644
index 000000000..fb6ede722
--- /dev/null
+++ b/pkg/integration/tests/branch/rebase_from_marked_base.go
@@ -0,0 +1,78 @@
+package branch
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var RebaseFromMarkedBase = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Rebase onto another branch from a marked base commit",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ NewBranch("base-branch").
+ EmptyCommit("one").
+ EmptyCommit("two").
+ EmptyCommit("three").
+ NewBranch("active-branch").
+ EmptyCommit("active one").
+ EmptyCommit("active two").
+ EmptyCommit("active three").
+ Checkout("base-branch").
+ NewBranch("target-branch").
+ EmptyCommit("target one").
+ EmptyCommit("target two").
+ Checkout("active-branch")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("active three"),
+ Contains("active two"),
+ Contains("active one"),
+ Contains("three"),
+ Contains("two"),
+ Contains("one"),
+ ).
+ NavigateToLine(Contains("active one")).
+ Press(keys.Commits.MarkCommitAsBaseForRebase).
+ Lines(
+ Contains("active three"),
+ Contains("active two"),
+ Contains("↑↑↑ Will rebase from here ↑↑↑ active one"),
+ Contains("three"),
+ Contains("two"),
+ Contains("one"),
+ )
+
+ t.Views().Information().Content(Contains("Marked a base commit for rebase"))
+
+ t.Views().Branches().
+ Focus().
+ Lines(
+ Contains("active-branch"),
+ Contains("target-branch"),
+ Contains("base-branch"),
+ ).
+ SelectNextItem().
+ Press(keys.Branches.RebaseBranch)
+
+ t.ExpectPopup().Menu().
+ Title(Equals("Rebase 'active-branch' from marked base onto 'target-branch'")).
+ Select(Contains("Simple rebase")).
+ Confirm()
+
+ t.Views().Commits().Lines(
+ Contains("active three"),
+ Contains("active two"),
+ Contains("target two"),
+ Contains("target one"),
+ Contains("three"),
+ Contains("two"),
+ Contains("one"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index 9dcb57dee..dfcd6c0ea 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -44,6 +44,7 @@ var tests = []*components.IntegrationTest{
branch.RebaseAndDrop,
branch.RebaseCancelOnConflict,
branch.RebaseDoesNotAutosquash,
+ branch.RebaseFromMarkedBase,
branch.Reset,
branch.ResetUpstream,
branch.SetUpstream,