diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-02-20 08:29:43 +0100 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2023-02-20 08:29:43 +0100 |
commit | c5cd217a6504259c4040402f6044b1d50ca3a410 (patch) | |
tree | 798ff218bf2bb09cfd24168497fc3f24159218b7 /pkg/integration | |
parent | 7351907474715c2bf86c6d52ef87b9d6d96d8f53 (diff) |
Allow squashing fixups above the first commit of a repo
This includes amending changes into a given commit, since that's implemented in
terms of the former.
Diffstat (limited to 'pkg/integration')
3 files changed, 92 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/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 0e1b3b01c..3bef44c7e 100644 --- a/pkg/integration/tests/tests_gen.go +++ b/pkg/integration/tests/tests_gen.go @@ -65,6 +65,7 @@ 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, @@ -73,6 +74,7 @@ var tests = []*components.IntegrationTest{ interactive_rebase.RewordFirstCommit, interactive_rebase.SquashDownFirstCommit, interactive_rebase.SquashDownSecondCommit, + interactive_rebase.SquashFixupsAboveFirstCommit, misc.ConfirmOnQuit, misc.InitialOpen, patch_building.CopyPatchToClipboard, |