diff options
53 files changed, 147 insertions, 0 deletions
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 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/FETCH_HEAD 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 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/MERGE_RR 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 Binary files differnew file mode 100644 index 000000000..193a6619c --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/index 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 <CI@example.com> 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 <CI@example.com> 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 Binary files differnew file mode 100644 index 000000000..57198442f --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 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 Binary files differnew file mode 100644 index 000000000..c4b48a2f0 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 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 Binary files differnew file mode 100644 index 000000000..98345f609 --- /dev/null +++ b/test/integration_new/commit/staged/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 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 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/FETCH_HEAD 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 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/MERGE_RR 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 Binary files differnew file mode 100644 index 000000000..3c44f83b5 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/index 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 <CI@example.com> 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 <CI@example.com> 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 Binary files differnew file mode 100644 index 000000000..cc6a8ec73 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/28/f8e24755d8792e66738e36f193949a68021709 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 Binary files differnew file mode 100644 index 000000000..57198442f --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/3a/e2df795236e3c84cb1faa242d3268838603515 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 Binary files differnew file mode 100644 index 000000000..c4b48a2f0 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/97/04090f88911a4083ef7d5907e38b9f45e43b16 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 Binary files differnew file mode 100644 index 000000000..98345f609 --- /dev/null +++ b/test/integration_new/commit/staging/expected/repo/.git_keep/objects/ad/a5661567ddf0a64f589cad3cd0cffd7e79af99 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 --- /dev/null +++ b/test/integration_new/commit/unstaged/expected/repo/.git_keep/FETCH_HEAD diff --git a/test/integration_new/commit/unstaged/expected/repo/.git_keep/HEAD b/test/integration_new/commit/unstaged/expe |