diff options
author | Arnaud PERALTA <arnaud.peralta@gmail.com> | 2022-11-28 19:40:29 +0100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-12-01 09:12:18 +1100 |
commit | 50b0d85cd37f26ac4f8277d2114896deb3f6008e (patch) | |
tree | c4d4867165798959833e8aa9721f7d26d2d480a0 | |
parent | bfcbf228bfcb653a402981f71f85fb5638a7644f (diff) |
integration tests for commit without pre-commit hooks in staging files menu
36 files changed, 124 insertions, 0 deletions
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 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/FETCH_HEAD 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 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/MERGE_RR 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 Binary files differnew file mode 100644 index 000000000..6ca933f52 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/index 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 <CI@example.com> 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 <CI@example.com> 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 Binary files differnew file mode 100644 index 000000000..75197c7e9 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa Binary files differnew file mode 100644 index 000000000..8a26026cd --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa 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 Binary files differnew file mode 100644 index 000000000..90e89ac27 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/4a/33e6274dd3bc702442966e6774e7688bb7af64 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 Binary files differnew file mode 100644 index 000000000..d746db209 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/refs/heads/master b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..8180a7984 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +4a33e6274dd3bc702442966e6774e7688bb7af64 diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/myfile b/test/integration_new/commit/staged_without_hooks/expected/repo/myfile new file mode 100644 index 000000000..45e15f2c1 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/myfile @@ -0,0 +1,2 @@ +myfile content +with a second line
\ No newline at end of file diff --git a/test/integration_new/commit/staged_without_hooks/expected/repo/myfile2 b/test/integration_new/commit/staged_without_hooks/expected/repo/myfile2 new file mode 100644 index 000000000..9704090f8 --- /dev/null +++ b/test/integration_new/commit/staged_without_hooks/expected/repo/myfile2 @@ -0,0 +1 @@ +myfile2 content
\ No newline at end of file diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..4a4f03e0a --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +WIPmy commit message diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/FETCH_HEAD diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/HEAD b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/MERGE_RR b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/MERGE_RR new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/MERGE_RR diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/config b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/config new file mode 100644 index 000000000..2b89b8630 --- /dev/null +++ b/test/integration_new/commit/unstaged_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/unstaged_without_hooks/expected/repo/.git_keep/description b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/commit/unstaged_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/unstaged_without_hooks/expected/repo/.git_keep/index b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/index Binary files differnew file mode 100644 index 000000000..e4b059071 --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/index diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/info/exclude b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/integration_new/commit/unstaged_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/unstaged_without_hooks/expected/repo/.git_keep/logs/HEAD b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..59e73348a --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 ebc03af0e92eb50f1ab1dec0697880ed9da9b02d CI <CI@example.com> 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 <CI@example.com> 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 Binary files differnew file mode 100644 index 000000000..5bdcb3903 --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/e7/bcdb57454dacf229e5be8122bb27bb56d78dba b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/e7/bcdb57454dacf229e5be8122bb27bb56d78dba new file mode 100644 index 000000000..765928979 --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/e7/bcdb57454dacf229e5be8122bb27bb56d78dba @@ -0,0 +1 @@ +x+)JMU06a040031QÈLËÌIe`xäf×ÅvYRú†j°\ì~µ]‡t³ö
Î
\ No newline at end of file diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/eb/c03af0e92eb50f1ab1dec0697880ed9da9b02d b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/eb/c03af0e92eb50f1ab1dec0697880ed9da9b02d Binary files differnew file mode 100644 index 000000000..138168db2 --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/eb/c03af0e92eb50f1ab1dec0697880ed9da9b02d diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/refs/heads/master b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..0cbc090e2 --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +ebc03af0e92eb50f1ab1dec0697880ed9da9b02d diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/myfile b/test/integration_new/commit/unstaged_without_hooks/expected/repo/myfile new file mode 100644 index 000000000..45e15f2c1 --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/myfile @@ -0,0 +1,2 @@ +myfile content +with a second line
\ No newline at end of file diff --git a/test/integration_new/commit/unstaged_without_hooks/expected/repo/myfile2 b/test/integration_new/commit/unstaged_without_hooks/expected/repo/myfile2 new file mode 100644 index 000000000..9704090f8 --- /dev/null +++ b/test/integration_new/commit/unstaged_without_hooks/expected/repo/myfile2 @@ -0,0 +1 @@ +myfile2 content
\ No newline at end of file |