From 50b0d85cd37f26ac4f8277d2114896deb3f6008e Mon Sep 17 00:00:00 2001 From: Arnaud PERALTA Date: Mon, 28 Nov 2022 19:40:29 +0100 Subject: [PATCH] integration tests for commit without pre-commit hooks in staging files menu --- .../tests/commit/staged_without_hooks.go | 34 ++++++++++++++++++ .../tests/commit/unstaged_without_hooks.go | 33 +++++++++++++++++ pkg/integration/tests/tests.go | 2 ++ .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../expected/repo/.git_keep/FETCH_HEAD | 0 .../expected/repo/.git_keep/HEAD | 1 + .../expected/repo/.git_keep/MERGE_RR | 0 .../expected/repo/.git_keep/config | 12 +++++++ .../expected/repo/.git_keep/description | 1 + .../expected/repo/.git_keep/index | Bin 0 -> 137 bytes .../expected/repo/.git_keep/info/exclude | 6 ++++ .../expected/repo/.git_keep/logs/HEAD | 1 + .../repo/.git_keep/logs/refs/heads/master | 1 + .../2c/32ecbb77ddbbb0584ceae9316e290da7733327 | Bin 0 -> 51 bytes .../45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa | Bin 0 -> 48 bytes .../4a/33e6274dd3bc702442966e6774e7688bb7af64 | Bin 0 -> 129 bytes .../a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 | Bin 0 -> 34 bytes .../expected/repo/.git_keep/refs/heads/master | 1 + .../staged_without_hooks/expected/repo/myfile | 2 ++ .../expected/repo/myfile2 | 1 + .../expected/repo/.git_keep/COMMIT_EDITMSG | 1 + .../expected/repo/.git_keep/FETCH_HEAD | 0 .../expected/repo/.git_keep/HEAD | 1 + .../expected/repo/.git_keep/MERGE_RR | 0 .../expected/repo/.git_keep/config | 12 +++++++ .../expected/repo/.git_keep/description | 1 + .../expected/repo/.git_keep/index | Bin 0 -> 137 bytes .../expected/repo/.git_keep/info/exclude | 6 ++++ .../expected/repo/.git_keep/logs/HEAD | 1 + .../repo/.git_keep/logs/refs/heads/master | 1 + .../00/e2463e8a06d3191bd825531e5dbf26bac22d6b | Bin 0 -> 31 bytes .../e7/bcdb57454dacf229e5be8122bb27bb56d78dba | 1 + .../eb/c03af0e92eb50f1ab1dec0697880ed9da9b02d | Bin 0 -> 129 bytes .../expected/repo/.git_keep/refs/heads/master | 1 + .../expected/repo/myfile | 2 ++ .../expected/repo/myfile2 | 1 + 36 files changed, 124 insertions(+) create mode 100644 pkg/integration/tests/commit/staged_without_hooks.go create mode 100644 pkg/integration/tests/commit/unstaged_without_hooks.go create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/HEAD create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/MERGE_RR create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/config create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/description create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/index create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/info/exclude create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/4a/33e6274dd3bc702442966e6774e7688bb7af64 create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/myfile create mode 100644 test/integration_new/commit/staged_without_hooks/expected/repo/myfile2 create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/FETCH_HEAD create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/HEAD create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/MERGE_RR create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/config create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/description create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/index create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/info/exclude create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/HEAD create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/e7/bcdb57454dacf229e5be8122bb27bb56d78dba create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/eb/c03af0e92eb50f1ab1dec0697880ed9da9b02d create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/refs/heads/master create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/myfile create mode 100644 test/integration_new/commit/unstaged_without_hooks/expected/repo/myfile2 diff --git a/pkg/integration/tests/commit/staged_without_hooks.go b/pkg/integration/tests/commit/staged_without_hooks.go new file mode 100644 index 000000000..e1466f8d2 --- /dev/null +++ b/pkg/integration/tests/commit/staged_without_hooks.go @@ -0,0 +1,34 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Staging a couple files, going in the staged files menu, unstaging a line then committing without pre-commit hooks", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + CreateFile("myfile", "myfile content\nwith a second line"). + CreateFile("myfile2", "myfile2 content") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.CommitCount(0) + + input.PrimaryAction() + input.Confirm() + input.PrimaryAction() + input.PressKeys(keys.Files.CommitChangesWithoutHook) + + commitMessage := "my commit message" + input.Type(commitMessage) + input.Confirm() + + assert.CommitCount(1) + assert.MatchHeadCommitMessage(Equals("WIP" + commitMessage)) + assert.CurrentWindowName("stagingSecondary") + }, +}) diff --git a/pkg/integration/tests/commit/unstaged_without_hooks.go b/pkg/integration/tests/commit/unstaged_without_hooks.go new file mode 100644 index 000000000..442316f60 --- /dev/null +++ b/pkg/integration/tests/commit/unstaged_without_hooks.go @@ -0,0 +1,33 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var UnstagedWithoutHooks = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Staging a couple files, going in the unstaged files menu, staging a line and committing without pre-commit hooks", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + CreateFile("myfile", "myfile content\nwith a second line"). + CreateFile("myfile2", "myfile2 content") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.CommitCount(0) + + input.Confirm() + input.PrimaryAction() + input.PressKeys(keys.Files.CommitChangesWithoutHook) + + commitMessage := "my commit message" + input.Type(commitMessage) + input.Confirm() + + assert.CommitCount(1) + assert.MatchHeadCommitMessage(Equals("WIP" + commitMessage)) + assert.CurrentWindowName("staging") + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 9b654ad80..6c4f60026 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -38,6 +38,8 @@ var tests = []*components.IntegrationTest{ commit.NewBranch, commit.Staged, commit.Unstaged, + commit.StagedWithoutHooks, + commit.UnstagedWithoutHooks, custom_commands.Basic, custom_commands.FormPrompts, custom_commands.MenuFromCommand, diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..4a4f03e0a --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +WIPmy commit message diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/HEAD b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/MERGE_RR b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/MERGE_RR new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/config b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/config new file mode 100644 index 000000000..2b89b8630 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/config @@ -0,0 +1,12 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true +[user] + email = CI@example.com + name = CI +[commit] + gpgSign = false +[protocol "file"] + allow = always diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/description b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/index b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/index new file mode 100644 index 0000000000000000000000000000000000000000..6ca933f528d0ac98960957621bb5edbbdb829a4b GIT binary patch literal 137 zcmZ?q402{*U|<4bMj*xk8kZnTEV1eGDhZ)#%E7LM_QbFoM zf?QpJlq7?pf&rI~(VN}ncXw}y@OkypFi(?rd9ktjd@cJ837$3Ix4d5J9P%X6RFaWf F4FK=XAe#UH literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/info/exclude b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/HEAD b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..1c6b9a7b2 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 4a33e6274dd3bc702442966e6774e7688bb7af64 CI 1669660775 +0100 commit (initial): WIPmy commit message diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..1c6b9a7b2 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 4a33e6274dd3bc702442966e6774e7688bb7af64 CI 1669660775 +0100 commit (initial): WIPmy commit message diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 new file mode 100644 index 0000000000000000000000000000000000000000..75197c7e913c978ccb4e12bcebe3e0bfb5d0a761 GIT binary patch literal 51 zcmb8X2`8f%gjktNY2kINzE(aD$gv*P)JlLP6Z02DCA`3r2+sa Gd=7F6eH0J? literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/4a/33e6274dd3bc702442966e6774e7688bb7af64 b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/4a/33e6274dd3bc702442966e6774e7688bb7af64 new file mode 100644 index 0000000000000000000000000000000000000000..90e89ac27dd35c72948602d26ababbac5f4db72e GIT binary patch literal 129 zcmV-{0Dk{?0ga8j3IZ_@0Il;C+Y7QuOxD052Un%Dv(95t!6kB+1O0ms`~llxhABoYT$Vhxv^iE7O`qdOf7Ck|G7HUVoQvep_>Y3=tm!xUkd;>hnLuO}Z$lQU@V jgZD_}V2>J6ZFHM-{!>@ic##kMDiB_lbYt}ez#lQ!Y$iHP literal 0 HcmV?d00001 diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 new file mode 100644 index 0000000000000000000000000000000000000000..d746db209b355034e77175036b466f51c7ccbd10 GIT binary patch literal 34 qcmb 1669660788 +0100 commit (initial): WIPmy commit message diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..59e73348a --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 ebc03af0e92eb50f1ab1dec0697880ed9da9b02d CI 1669660788 +0100 commit (initial): WIPmy commit message diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b new file mode 100644 index 0000000000000000000000000000000000000000..5bdcb3903da65756ce19935b40720e2a49776c17 GIT binary patch literal 31 ncmboYU3r&0<1h-1y=YHegB4#rv{>xs}+A1Y;)-~HZZm=YYObmBG3>&g4l