From 66de981e9108c83ddb1d778eb92e948050c85311 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 11 Jun 2023 08:08:55 +0200 Subject: Add a "Mark commit as base commit for rebase" command This allows to do the equivalent of "git rebase --onto ", by first marking the commit with the new command, and then selecting the target branch and invoking the usual rebase command there. --- .../tests/branch/rebase_from_marked_base.go | 78 ++++++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 79 insertions(+) create mode 100644 pkg/integration/tests/branch/rebase_from_marked_base.go (limited to 'pkg/integration') 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, -- cgit v1.2.3