summaryrefslogtreecommitdiffstats
path: root/pkg/integration
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-02-20 19:21:37 +1100
committerGitHub <noreply@github.com>2023-02-20 19:21:37 +1100
commite1c376ef5490f3e964ee8c5bd554957c05c60884 (patch)
treee56451c32f53f3949b3a5d730b36ecd38d2c7bfd /pkg/integration
parentc13f550d634a4bda12a244d67f4363a59dc05fb4 (diff)
parentc5cd217a6504259c4040402f6044b1d50ca3a410 (diff)
Merge pull request #2453 from stefanhaller/allow-rebasing-to-first-commit
Diffstat (limited to 'pkg/integration')
-rw-r--r--pkg/integration/tests/interactive_rebase/amend_first_commit.go41
-rw-r--r--pkg/integration/tests/interactive_rebase/edit_first_commit.go38
-rw-r--r--pkg/integration/tests/interactive_rebase/fixup_first_commit.go37
-rw-r--r--pkg/integration/tests/interactive_rebase/fixup_second_commit.go44
-rw-r--r--pkg/integration/tests/interactive_rebase/reword_first_commit.go39
-rw-r--r--pkg/integration/tests/interactive_rebase/squash_down_first_commit.go37
-rw-r--r--pkg/integration/tests/interactive_rebase/squash_down_second_commit.go43
-rw-r--r--pkg/integration/tests/interactive_rebase/squash_fixups_above_first_commit.go49
-rw-r--r--pkg/integration/tests/tests_gen.go8
9 files changed, 336 insertions, 0 deletions
diff --git a/pkg/integration/tests/interactive_rebase/amend_first_commit.go b/pkg/integration/tests/interactive_rebase/amend_first_commit.go
new file mode 100644
index 000000000..d03a880b9
--- /dev/null
+++ b/pkg/integration/tests/interactive_rebase/amend_first_commit.go
@@ -0,0 +1,41 @@
+package interactive_rebase
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var AmendFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Amends a staged file to the first (initial) commit.",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ CreateNCommits(2).
+ CreateFileAndAdd("fixup-file", "fixup content")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01"),
+ ).
+ NavigateToListItem(Contains("commit 01")).
+ Press(keys.Commits.AmendToCommit).
+ Tap(func() {
+ t.ExpectPopup().Confirmation().
+ Title(Equals("Amend Commit")).
+ Content(Contains("Are you sure you want to amend this commit with your staged files?")).
+ Confirm()
+ }).
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01").IsSelected(),
+ )
+
+ t.Views().Main().
+ Content(Contains("fixup content"))
+ },
+})
diff --git a/pkg/integration/tests/interactive_rebase/edit_first_commit.go b/pkg/integration/tests/interactive_rebase/edit_first_commit.go
new file mode 100644
index 000000000..def3b7fca
--- /dev/null
+++ b/pkg/integration/tests/interactive_rebase/edit_first_commit.go
@@ -0,0 +1,38 @@
+package interactive_rebase
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var EditFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Edits the first commit, just to show that it's possible",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ CreateNCommits(2)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01"),
+ ).
+ NavigateToListItem(Contains("commit 01")).
+ Press(keys.Universal.Edit).
+ Lines(
+ Contains("commit 02"),
+ MatchesRegexp("YOU ARE HERE.*commit 01").IsSelected(),
+ ).
+ Tap(func() {
+ t.Actions().ContinueRebase()
+ }).
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/interactive_rebase/fixup_first_commit.go b/pkg/integration/tests/interactive_rebase/fixup_first_commit.go
new file mode 100644
index 000000000..fe339f3e2
--- /dev/null
+++ b/pkg/integration/tests/interactive_rebase/fixup_first_commit.go
@@ -0,0 +1,37 @@
+package interactive_rebase
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var FixupFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Tries to fixup the first commit, which results in an error message",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ CreateNCommits(2)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01"),
+ ).
+ NavigateToListItem(Contains("commit 01")).
+ Press(keys.Commits.MarkCommitAsFixup).
+ Tap(func() {
+ t.ExpectPopup().Alert().
+ Title(Equals("Error")).
+ Content(Equals("There's no commit below to squash into")).
+ Confirm()
+ }).
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/interactive_rebase/fixup_second_commit.go b/pkg/integration/tests/interactive_rebase/fixup_second_commit.go
new file mode 100644
index 000000000..007eba84f
--- /dev/null
+++ b/pkg/integration/tests/interactive_rebase/fixup_second_commit.go
@@ -0,0 +1,44 @@
+package interactive_rebase
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var FixupSecondCommit = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Fixup the second commit into the first (initial)",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ CreateNCommits(3)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("commit 03"),
+ Contains("commit 02"),
+ Contains("commit 01"),
+ ).
+ NavigateToListItem(Contains("commit 02")).
+ Press(keys.Commits.MarkCommitAsFixup).
+ Tap(func() {
+ t.ExpectPopup().Confirmation().
+ Title(Equals("Fixup")).
+ Content(Equals("Are you sure you want to 'fixup' this commit? It will be merged into the commit below")).
+ Confirm()
+ }).
+ Lines(
+ Contains("commit 03"),
+ Contains("commit 01").IsSelected(),
+ )
+
+ t.Views().Main().
+ Content(Contains("commit 01")).
+ Content(DoesNotContain("commit 02")).
+ Content(Contains("+file01 content")).
+ Content(Contains("+file02 content"))
+ },
+})
diff --git a/pkg/integration/tests/interactive_rebase/reword_first_commit.go b/pkg/integration/tests/interactive_rebase/reword_first_commit.go
new file mode 100644
index 000000000..9e631da09
--- /dev/null
+++ b/pkg/integration/tests/interactive_rebase/reword_first_commit.go
@@ -0,0 +1,39 @@
+package interactive_rebase
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var RewordFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Rewords the first commit, just to show that it's possible",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ CreateNCommits(2)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01"),
+ ).
+ NavigateToListItem(Contains("commit 01")).
+ Press(keys.Commits.RenameCommit).
+ Tap(func() {
+ t.ExpectPopup().Prompt().
+ Title(Equals("reword commit")).
+ InitialText(Equals("commit 01")).
+ Clear().
+ Type("renamed 01").
+ Confirm()
+ }).
+ Lines(
+ Contains("commit 02"),
+ Contains("renamed 01"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/interactive_rebase/squash_down_first_commit.go b/pkg/integration/tests/interactive_rebase/squash_down_first_commit.go
new file mode 100644
index 000000000..0ec334a6c
--- /dev/null
+++ b/pkg/integration/tests/interactive_rebase/squash_down_first_commit.go
@@ -0,0 +1,37 @@
+package interactive_rebase
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var SquashDownFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Tries to squash down the first commit, which results in an error message",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ CreateNCommits(2)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01"),
+ ).
+ NavigateToListItem(Contains("commit 01")).
+ Press(keys.Commits.SquashDown).
+ Tap(func() {
+ t.ExpectPopup().Alert().
+ Title(Equals("Error")).
+ Content(Equals("There's no commit below to squash into")).
+ Confirm()
+ }).
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01"),
+ )
+ },
+})
diff --git a/pkg/integration/tests/interactive_rebase/squash_down_second_commit.go b/pkg/integration/tests/interactive_rebase/squash_down_second_commit.go
new file mode 100644
index 000000000..ffa54584f
--- /dev/null
+++ b/pkg/integration/tests/interactive_rebase/squash_down_second_commit.go
@@ -0,0 +1,43 @@
+package interactive_rebase
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var SquashDownSecondCommit = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Squash down the second commit into the first (initial)",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ CreateNCommits(3)
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("commit 03"),
+ Contains("commit 02"),
+ Contains("commit 01"),
+ ).
+ NavigateToListItem(Contains("commit 02")).
+ Press(keys.Commits.SquashDown).
+ Tap(func() {
+ t.ExpectPopup().Confirmation().
+ Title(Equals("Squash")).
+ Content(Equals("Are you sure you want to squash this commit into the commit below?")).
+ Confirm()
+ }).
+ Lines(
+ Contains("commit 03"),
+ Contains("commit 01").IsSelected(),
+ )
+
+ t.Views().Main().
+ Content(Contains(" commit 01\n \n commit 02")).
+ Content(Contains("+file01 content")).
+ Content(Contains("+file02 content"))
+ },
+})
diff --git a/pkg/integration/tests/interactive_rebase/squash_fixups_above_first_commit.go b/pkg/integration/tests/interactive_rebase/squash_fixups_above_first_commit.go
new file mode 100644
index 000000000..ece1e5fae
--- /dev/null
+++ b/pkg/integration/tests/interactive_rebase/squash_fixups_above_first_commit.go
@@ -0,0 +1,49 @@
+package interactive_rebase
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var SquashFixupsAboveFirstCommit = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Squashes all fixups above the first (initial) commit.",
+ ExtraCmdArgs: "",
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.
+ CreateNCommits(2).
+ CreateFileAndAdd("fixup-file", "fixup content")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ t.Views().Commits().
+ Focus().
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01"),
+ ).
+ NavigateToListItem(Contains("commit 01")).
+ Press(keys.Commits.CreateFixupCommit).
+ Tap(func() {
+ t.ExpectPopup().Confirmation().
+ Title(Equals("Create fixup commit")).
+ Content(Contains("Are you sure you want to create a fixup! commit for commit")).
+ Confirm()
+ }).
+ NavigateToListItem(Contains("commit 01")).
+ Press(keys.Commits.SquashAboveCommits).
+ Tap(func() {
+ t.ExpectPopup().Confirmation().
+ Title(Equals("Squash all 'fixup!' commits above selected commit (autosquash)")).
+ Content(Contains("Are you sure you want to squash all fixup! commits above")).
+ Confirm()
+ }).
+ Lines(
+ Contains("commit 02"),
+ Contains("commit 01").IsSelected(),
+ )
+
+ t.Views().Main().
+ Content(Contains("fixup content"))
+ },
+})
diff --git a/pkg/integration/tests/tests_gen.go b/pkg/integration/tests/tests_gen.go
index e2336f6be..27ca095c1 100644
--- a/pkg/integration/tests/tests_gen.go
+++ b/pkg/integration/tests/tests_gen.go
@@ -68,8 +68,16 @@ var tests = []*components.IntegrationTest{
filter_by_path.CliArg,
filter_by_path.SelectFile,
filter_by_path.TypeFile,
+ interactive_rebase.AmendFirstCommit,
interactive_rebase.AmendMerge,
+ interactive_rebase.EditFirstCommit,
+ interactive_rebase.FixupFirstCommit,
+ interactive_rebase.FixupSecondCommit,
interactive_rebase.One,
+ interactive_rebase.RewordFirstCommit,
+ interactive_rebase.SquashDownFirstCommit,
+ interactive_rebase.SquashDownSecondCommit,
+ interactive_rebase.SquashFixupsAboveFirstCommit,
misc.ConfirmOnQuit,
misc.InitialOpen,
patch_building.CopyPatchToClipboard,