diff --git a/pkg/integration/components/shell.go b/pkg/integration/components/shell.go index 5f7fef350..1d8182edb 100644 --- a/pkg/integration/components/shell.go +++ b/pkg/integration/components/shell.go @@ -111,3 +111,8 @@ func (s *Shell) CreateNCommits(n int) *Shell { return s } + +func (s *Shell) StashWithMessage(message string) *Shell { + s.RunCommand(fmt.Sprintf(`git stash -m "%s"`, message)) + return s +} diff --git a/pkg/integration/tests/stash/rename.go b/pkg/integration/tests/stash/rename.go new file mode 100644 index 000000000..97cfae006 --- /dev/null +++ b/pkg/integration/tests/stash/rename.go @@ -0,0 +1,33 @@ +package stash + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var Rename = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Try to rename the stash.", + ExtraCmdArgs: "", + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + EmptyCommit("blah"). + CreateFileAndAdd("foo", "change to stash"). + StashWithMessage("bar") + }, + Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) { + input.SwitchToStashWindow() + assert.CurrentViewName("stash") + + assert.MatchSelectedLine(Equals("On master: bar")) + input.PressKeys(keys.Stash.RenameStash) + assert.InPrompt() + assert.MatchCurrentViewTitle(Equals("Rename stash: stash@{0}")) + + input.Type(" baz") + input.Confirm() + + assert.MatchSelectedLine(Equals("On master: bar baz")) + }, +}) diff --git a/pkg/integration/tests/tests.go b/pkg/integration/tests/tests.go index 21f06a376..6b4583e6d 100644 --- a/pkg/integration/tests/tests.go +++ b/pkg/integration/tests/tests.go @@ -16,6 +16,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/integration/tests/commit" "github.com/jesseduffield/lazygit/pkg/integration/tests/custom_commands" "github.com/jesseduffield/lazygit/pkg/integration/tests/interactive_rebase" + "github.com/jesseduffield/lazygit/pkg/integration/tests/stash" ) // Here is where we lists the actual tests that will run. When you create a new test, @@ -38,6 +39,7 @@ var tests = []*components.IntegrationTest{ cherry_pick.CherryPick, cherry_pick.CherryPickConflicts, custom_commands.FormPrompts, + stash.Rename, } func GetTests() []*components.IntegrationTest { diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/COMMIT_EDITMSG b/test/integration_new/stash/rename/expected/repo/.git_keep/COMMIT_EDITMSG new file mode 100644 index 000000000..907b30816 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/COMMIT_EDITMSG @@ -0,0 +1 @@ +blah diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/FETCH_HEAD b/test/integration_new/stash/rename/expected/repo/.git_keep/FETCH_HEAD new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/HEAD b/test/integration_new/stash/rename/expected/repo/.git_keep/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/ORIG_HEAD b/test/integration_new/stash/rename/expected/repo/.git_keep/ORIG_HEAD new file mode 100644 index 000000000..4db7189cb --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/ORIG_HEAD @@ -0,0 +1 @@ +8d4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/commit-template.txt b/test/integration_new/stash/rename/expected/repo/.git_keep/commit-template.txt new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/config b/test/integration_new/stash/rename/expected/repo/.git_keep/config new file mode 100644 index 000000000..8a748ce32 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/config @@ -0,0 +1,12 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true + precomposeunicode = true +[user] + email = CI@example.com + name = CI +[commit] + gpgSign = false diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/description b/test/integration_new/stash/rename/expected/repo/.git_keep/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/index b/test/integration_new/stash/rename/expected/repo/.git_keep/index new file mode 100644 index 000000000..65d675154 Binary files /dev/null and b/test/integration_new/stash/rename/expected/repo/.git_keep/index differ diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/info/exclude b/test/integration_new/stash/rename/expected/repo/.git_keep/info/exclude new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/logs/HEAD b/test/integration_new/stash/rename/expected/repo/.git_keep/logs/HEAD new file mode 100644 index 000000000..bca9be914 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 8d4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf CI 1665802395 +0900 commit (initial): blah +8d4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf 8d4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf CI 1665802396 +0900 reset: moving to HEAD diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/heads/master b/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/heads/master new file mode 100644 index 000000000..698928dd3 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 8d4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf CI 1665802395 +0900 commit (initial): blah diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/stash b/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/stash new file mode 100644 index 000000000..02b7af510 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/logs/refs/stash @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 c6f35659c0cf57c794d79df88283d7ee933831dd CI 1665802399 +0900 On master: bar baz diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/objects/25/0122ffb92a8c1c2a6554ce2ac84b49e5f3afe3 b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/25/0122ffb92a8c1c2a6554ce2ac84b49e5f3afe3 new file mode 100644 index 000000000..2a62b4b9d Binary files /dev/null and b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/25/0122ffb92a8c1c2a6554ce2ac84b49e5f3afe3 differ diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 new file mode 100644 index 000000000..adf64119a Binary files /dev/null and b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 differ diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/objects/4d/ff185ecddfb638f76215fa07adde0f4e97da7c b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/4d/ff185ecddfb638f76215fa07adde0f4e97da7c new file mode 100644 index 000000000..6d964ed92 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/4d/ff185ecddfb638f76215fa07adde0f4e97da7c @@ -0,0 +1,2 @@ +xA +0E)f_(1)\yd2Q)x龋לKE@1@TmDi&vUrf ,|je\wxKYn'T&%k͹QEʹ$9`] a4_C^ \ No newline at end of file diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/objects/8d/4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/8d/4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf new file mode 100644 index 000000000..98e81aa49 --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/8d/4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf @@ -0,0 +1,2 @@ +x +0 a}ɺ4$ "h +Qw烿Z_/p2i)LiFFOd,Qd5wR?}kL3ܧ\߻J`51t~?+ \ No newline at end of file diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/objects/c6/f35659c0cf57c794d79df88283d7ee933831dd b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/c6/f35659c0cf57c794d79df88283d7ee933831dd new file mode 100644 index 000000000..0eda98367 Binary files /dev/null and b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/c6/f35659c0cf57c794d79df88283d7ee933831dd differ diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/objects/fc/66bff0a9fdfe660b6e490dc217a9c26ffc5fff b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/fc/66bff0a9fdfe660b6e490dc217a9c26ffc5fff new file mode 100644 index 000000000..77bae3f92 Binary files /dev/null and b/test/integration_new/stash/rename/expected/repo/.git_keep/objects/fc/66bff0a9fdfe660b6e490dc217a9c26ffc5fff differ diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/refs/heads/master b/test/integration_new/stash/rename/expected/repo/.git_keep/refs/heads/master new file mode 100644 index 000000000..4db7189cb --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/refs/heads/master @@ -0,0 +1 @@ +8d4897b3dcbb5c8fbc8fa8439ec7e9627c3159cf diff --git a/test/integration_new/stash/rename/expected/repo/.git_keep/refs/stash b/test/integration_new/stash/rename/expected/repo/.git_keep/refs/stash new file mode 100644 index 000000000..c467f289e --- /dev/null +++ b/test/integration_new/stash/rename/expected/repo/.git_keep/refs/stash @@ -0,0 +1 @@ +c6f35659c0cf57c794d79df88283d7ee933831dd