diff --git a/pkg/integration/tests/commit/staged.go b/pkg/integration/tests/commit/staged.go new file mode 100644 index 000000000..80de2bca9 --- /dev/null +++ b/pkg/integration/tests/commit/staged.go @@ -0,0 +1,33 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var Staged = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Staging a couple files, going in the staged files menu and committing", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFile("myfile", "myfile content") + shell.CreateFile("myfile2", "myfile2 content") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.CommitCount(0) + + input.PrimaryAction() + input.NextItem() + input.PrimaryAction() + input.Confirm() + input.PressKeys(keys.Files.CommitChanges) + + commitMessage := "my commit message" + input.Type(commitMessage) + input.Confirm() + + assert.CommitCount(1) + assert.MatchHeadCommitMessage(Equals(commitMessage)) + }, +}) diff --git a/pkg/integration/tests/commit/unstaged.go b/pkg/integration/tests/commit/unstaged.go new file mode 100644 index 000000000..5dd396eec --- /dev/null +++ b/pkg/integration/tests/commit/unstaged.go @@ -0,0 +1,32 @@ +package commit + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var Unstaged = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Staging a couple files, going in the unstaged files menu and committing", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFile("myfile", "myfile content") + shell.CreateFile("myfile2", "myfile2 content") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + assert.CommitCount(0) + + input.PrimaryAction() + input.NextItem() + input.Confirm() + input.PressKeys(keys.Files.CommitChanges) + + commitMessage := "my commit message" + input.Type(commitMessage) + input.Confirm() + + assert.CommitCount(1) + assert.MatchHeadCommitMessage(Equals(commitMessage)) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 6c074bb10..9b654ad80 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -36,6 +36,8 @@ var tests = []*components.IntegrationTest{ cherry_pick.CherryPickConflicts, commit.Commit, commit.NewBranch, + commit.Staged, + commit.Unstaged, custom_commands.Basic, custom_commands.FormPrompts, custom_commands.MenuFromCommand, diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/staged/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..8a744b4fe --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +my commit message diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/staged/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/HEAD b/test/integration_new/commit/staged/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/MERGE_RR b/test/integration_new/commit/staged/expected/repo/.git_keep/MERGE_RR new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/config b/test/integration_new/commit/staged/expected/repo/.git_keep/config new file mode 100644 index 000000000..2b89b8630 --- /dev/null +++ b/test/integration_new/commit/staged/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/expected/repo/.git_keep/description b/test/integration_new/commit/staged/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/commit/staged/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/expected/repo/.git_keep/index b/test/integration_new/commit/staged/expected/repo/.git_keep/index new file mode 100644 index 000000000..193a6619c Binary files /dev/null and b/test/integration_new/commit/staged/expected/repo/.git_keep/index differ diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/info/exclude b/test/integration_new/commit/staged/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/integration_new/commit/staged/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/expected/repo/.git_keep/logs/HEAD b/test/integration_new/commit/staged/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..40d31f9ee --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 ef3197feca3fdc5b9f0170f483c6ff138d5cf186 CI 1669566692 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..40d31f9ee --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 ef3197feca3fdc5b9f0170f483c6ff138d5cf186 CI 1669566692 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 new file mode 100644 index 000000000..57198442f Binary files /dev/null and b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 differ diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 new file mode 100644 index 000000000..c4b48a2f0 Binary files /dev/null and b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 differ diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 new file mode 100644 index 000000000..98345f609 Binary files /dev/null and b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 differ diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/objects/ef/3197feca3fdc5b9f0170f483c6ff138d5cf186 b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/ef/3197feca3fdc5b9f0170f483c6ff138d5cf186 new file mode 100644 index 000000000..11512bf51 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/ef/3197feca3fdc5b9f0170f483c6ff138d5cf186 @@ -0,0 +1,2 @@ +xA +0E]$iDz1Fn?GyWWU QcX)._,N%Ct0i/[zm>xm'Uԝ}M0 \ No newline at end of file diff --git a/test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master b/test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..b44143ba4 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +ef3197feca3fdc5b9f0170f483c6ff138d5cf186 diff --git a/test/integration_new/commit/staged/expected/repo/myfile b/test/integration_new/commit/staged/expected/repo/myfile new file mode 100644 index 000000000..ada566156 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/myfile @@ -0,0 +1 @@ +myfile content \ No newline at end of file diff --git a/test/integration_new/commit/staged/expected/repo/myfile2 b/test/integration_new/commit/staged/expected/repo/myfile2 new file mode 100644 index 000000000..9704090f8 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/myfile2 @@ -0,0 +1 @@ +myfile2 content \ No newline at end of file diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..8a744b4fe --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +my commit message diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/staging/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/HEAD b/test/integration_new/commit/staging/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/MERGE_RR b/test/integration_new/commit/staging/expected/repo/.git_keep/MERGE_RR new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/config b/test/integration_new/commit/staging/expected/repo/.git_keep/config new file mode 100644 index 000000000..2b89b8630 --- /dev/null +++ b/test/integration_new/commit/staging/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/staging/expected/repo/.git_keep/description b/test/integration_new/commit/staging/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/commit/staging/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/staging/expected/repo/.git_keep/index b/test/integration_new/commit/staging/expected/repo/.git_keep/index new file mode 100644 index 000000000..3c44f83b5 Binary files /dev/null and b/test/integration_new/commit/staging/expected/repo/.git_keep/index differ diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/info/exclude b/test/integration_new/commit/staging/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/integration_new/commit/staging/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/staging/expected/repo/.git_keep/logs/HEAD b/test/integration_new/commit/staging/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..910749aff --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 28f8e24755d8792e66738e36f193949a68021709 CI 1669566470 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..910749aff --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 28f8e24755d8792e66738e36f193949a68021709 CI 1669566470 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/objects/28/f8e24755d8792e66738e36f193949a68021709 b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/28/f8e24755d8792e66738e36f193949a68021709 new file mode 100644 index 000000000..cc6a8ec73 Binary files /dev/null and b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/28/f8e24755d8792e66738e36f193949a68021709 differ diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 new file mode 100644 index 000000000..57198442f Binary files /dev/null and b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 differ diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 new file mode 100644 index 000000000..c4b48a2f0 Binary files /dev/null and b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 differ diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 new file mode 100644 index 000000000..98345f609 Binary files /dev/null and b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 differ diff --git a/test/integration_new/commit/staging/expected/repo/.git_keep/refs/heads/master b/test/integration_new/commit/staging/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..3bc6acf4d --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +28f8e24755d8792e66738e36f193949a68021709 diff --git a/test/integration_new/commit/staging/expected/repo/myfile b/test/integration_new/commit/staging/expected/repo/myfile new file mode 100644 index 000000000..ada566156 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/myfile @@ -0,0 +1 @@ +myfile content \ No newline at end of file diff --git a/test/integration_new/commit/staging/expected/repo/myfile2 b/test/integration_new/commit/staging/expected/repo/myfile2 new file mode 100644 index 000000000..9704090f8 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/myfile2 @@ -0,0 +1 @@ +myfile2 content \ No newline at end of file diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/commit/unstaged/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..8a744b4fe --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +my commit message diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/commit/unstaged/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/HEAD b/test/integration_new/commit/unstaged/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/MERGE_RR b/test/integration_new/commit/unstaged/expected/repo/.git_keep/MERGE_RR new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/config b/test/integration_new/commit/unstaged/expected/repo/.git_keep/config new file mode 100644 index 000000000..2b89b8630 --- /dev/null +++ b/test/integration_new/commit/unstaged/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/expected/repo/.git_keep/description b/test/integration_new/commit/unstaged/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/commit/unstaged/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/expected/repo/.git_keep/index b/test/integration_new/commit/unstaged/expected/repo/.git_keep/index new file mode 100644 index 000000000..617e78b3a Binary files /dev/null and b/test/integration_new/commit/unstaged/expected/repo/.git_keep/index differ diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/info/exclude b/test/integration_new/commit/unstaged/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..a5196d1be --- /dev/null +++ b/test/integration_new/commit/unstaged/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/expected/repo/.git_keep/logs/HEAD b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..c2cf4bcdd --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 d46951396fe8179592ec90aee0c0414fc0512fc5 CI 1669566705 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..c2cf4bcdd --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 d46951396fe8179592ec90aee0c0414fc0512fc5 CI 1669566705 +0100 commit (initial): my commit message diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/0c/4369dfc55cd41da90e149f2fa8ee3fc0a8f297 b/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/0c/4369dfc55cd41da90e149f2fa8ee3fc0a8f297 new file mode 100644 index 000000000..79af4f45f Binary files /dev/null and b/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/0c/4369dfc55cd41da90e149f2fa8ee3fc0a8f297 differ diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 b/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 new file mode 100644 index 000000000..98345f609 Binary files /dev/null and b/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 differ diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/d4/6951396fe8179592ec90aee0c0414fc0512fc5 b/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/d4/6951396fe8179592ec90aee0c0414fc0512fc5 new file mode 100644 index 000000000..e7083f1ce Binary files /dev/null and b/test/integration_new/commit/unstaged/expected/repo/.git_keep/objects/d4/6951396fe8179592ec90aee0c0414fc0512fc5 differ diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/refs/heads/master b/test/integration_new/commit/unstaged/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..e504af29a --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +d46951396fe8179592ec90aee0c0414fc0512fc5 diff --git a/test/integration_new/commit/unstaged/expected/repo/myfile b/test/integration_new/commit/unstaged/expected/repo/myfile new file mode 100644 index 000000000..ada566156 --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/myfile @@ -0,0 +1 @@ +myfile content \ No newline at end of file diff --git a/test/integration_new/commit/unstaged/expected/repo/myfile2 b/test/integration_new/commit/unstaged/expected/repo/myfile2 new file mode 100644 index 000000000..9704090f8 --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/myfile2 @@ -0,0 +1 @@ +myfile2 content \ No newline at end of file