summaryrefslogtreecommitdiffstats
path: root/pkg/integration/tests/interactive_rebase/squash_fixups_in_current_branch.go
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-01-29 10:05:40 +0100
committerGitHub <noreply@github.com>2024-01-29 10:05:40 +0100
commit9d840088ace91bce355d0542a8a189f9e77e07ec (patch)
tree012317915bba9ee915508e5727ef25e2fbd62060 /pkg/integration/tests/interactive_rebase/squash_fixups_in_current_branch.go
parent24e79a057c6ef39d5153a65cacedcdb419d9c7fd (diff)
parentb133318b40f9863e9952dddd8acfeffa6dc95b71 (diff)
Add command to squash all fixups in the current branch (#3274)
Add command to squash all fixups in the current branch. To do that, change the "Apply fixup commits" command to show a menu with the two choices "in current branch" and "above the selected commit"; we make "in current branch" the default, as it's the more useful one most of the time, even though it is a breaking change for those who are used to "shift-S enter" meaning "squash above selected". Fixes #3263.
Diffstat (limited to 'pkg/integration/tests/interactive_rebase/squash_fixups_in_current_branch.go')
-rw-r--r--pkg/integration/tests/interactive_rebase/squash_fixups_in_current_branch.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/pkg/integration/tests/interactive_rebase/squash_fixups_in_current_branch.go b/pkg/integration/tests/interactive_rebase/squash_fixups_in_current_branch.go
new file mode 100644
index 000000000..636810533
--- /dev/null
+++ b/pkg/integration/tests/interactive_rebase/squash_fixups_in_current_branch.go
@@ -0,0 +1,55 @@
+package interactive_rebase
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var SquashFixupsInCurrentBranch = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Squashes all fixups in the current branch.",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ CreateFileAndAdd("file1", "file1").
+ Commit("master commit").
+ NewBranch("branch").
+ // Test the pathological case that the first commit of a branch is a
+ // fixup for the last master commit below it. We _don't_ want this to
+ // be squashed.
+ UpdateFileAndAdd("file1", "changed file1").
+ Commit("fixup! master commit").
+ CreateNCommits(2).
+ CreateFileAndAdd("fixup-file", "fixup content").
+ Commit("fixup! commit 01")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("fixup! commit 01"),
+ Contains("commit 02"),
+ Contains("commit 01"),
+ Contains("fixup! master commit"),
+ Contains("master commit"),
+ ).
+ Press(keys.Commits.SquashAboveCommits).
+ Tap(func() {
+ t.ExpectPopup().Menu().
+ Title(Equals("Apply fixup commits")).
+ Select(Contains("In current branch")).
+ Confirm()
+ }).
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01"),
+ Contains("fixup! master commit"),
+ Contains("master commit"),
+ ).
+ NavigateToLine(Contains("commit 01"))
+
+ t.Views().Main().
+ Content(Contains("fixup content"))
+ },
+})