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 000000000..6ca933f52 Binary files /dev/null and b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/index differ 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 000000000..75197c7e9 Binary files /dev/null and b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/2c/32ecbb77ddbbb0584ceae9316e290da7733327 differ 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 new file mode 100644 index 000000000..8a26026cd Binary files /dev/null and b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/45/e15f2c1a4f47adeba3dbfc075e46a574f9b1fa differ 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 000000000..90e89ac27 Binary files /dev/null and b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/4a/33e6274dd3bc702442966e6774e7688bb7af64 differ 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 000000000..d746db209 Binary files /dev/null and b/test/integration_new/commit/staged_without_hooks/expected/repo/.git_keep/objects/a4/de8e0658023fb43037b687b5052c1b5b2ab0c3 differ 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 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 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 new file mode 100644 index 000000000..e4b059071 Binary files /dev/null and b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/index differ 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 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 000000000..5bdcb3903 Binary files /dev/null and b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/00/e2463e8a06d3191bd825531e5dbf26bac22d6b differ 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 new file mode 100644 index 000000000..138168db2 Binary files /dev/null and b/test/integration_new/commit/unstaged_without_hooks/expected/repo/.git_keep/objects/eb/c03af0e92eb50f1ab1dec0697880ed9da9b02d differ 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