diff options
author | dsolerhww <d.soler@whatwapp.com> | 2024-05-17 21:36:28 +0300 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-05-18 09:59:00 +0200 |
commit | 5b80c0c7926da42e1126b817513f440513dc4e5c (patch) | |
tree | 2feda50e68deb380878e83cf5f6d2f40f9380b8e /pkg/integration | |
parent | d8b3c0e5681ff92a554a9ba81671e9ac10246d17 (diff) |
Fix stashing partialy staged files for git version >= 2.35.0
Use `git stash push --staged` git feature available on git version >
2.35.0.
Diffstat (limited to 'pkg/integration')
-rw-r--r-- | pkg/integration/tests/stash/stash_staged_partial_file.go | 70 | ||||
-rw-r--r-- | pkg/integration/tests/test_list.go | 1 |
2 files changed, 71 insertions, 0 deletions
diff --git a/pkg/integration/tests/stash/stash_staged_partial_file.go b/pkg/integration/tests/stash/stash_staged_partial_file.go new file mode 100644 index 000000000..d9ac30e1b --- /dev/null +++ b/pkg/integration/tests/stash/stash_staged_partial_file.go @@ -0,0 +1,70 @@ +package stash + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StashStagedPartialFile = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Stash staged changes when a file is partially staged", + ExtraCmdArgs: []string{}, + GitVersion: AtLeast("git version 2.35.0"), + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.CreateFileAndAdd("file-staged", "line1\nline2\nline3\nline4\n") + shell.Commit("initial commit") + shell.UpdateFile("file-staged", "line1\nline2 mod\nline3\nline4 mod\n") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Files(). + IsFocused(). + PressEnter() + + t.Views().Staging(). + Content( + Contains(" line1\n-line2\n+line2 mod\n line3\n-line4\n+line4 mod\n"), + ). + PressPrimaryAction(). + PressPrimaryAction(). + Content( + Contains(" line1\n line2 mod\n line3\n-line4\n+line4 mod\n"), + ). + PressEscape() + + t.Views().Files(). + IsFocused(). + Press(keys.Files.ViewStashOptions) + + t.ExpectPopup().Menu().Title(Equals("Stash options")).Select(MatchesRegexp("Stash staged changes$")).Confirm() + + t.ExpectPopup().Prompt().Title(Equals("Stash changes")).Type("my stashed file").Confirm() + + t.Views().Stash(). + Focus(). + Lines( + Contains("my stashed file"), + ). + PressEnter() + + t.Views().CommitFiles(). + IsFocused(). + Lines( + Contains("file-staged").IsSelected(), + ) + t.Views().Main(). + Content( + Contains(" line1\n-line2\n+line2 mod\n line3\n line4\n"), + ) + + t.Views().Files(). + Lines( + Contains("file-staged"), + ) + + t.Views().Staging(). + Content( + Contains(" line1\n line2\n line3\n-line4\n+line4 mod\n"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index bf6264cde..2548702e9 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -257,6 +257,7 @@ var tests = []*components.IntegrationTest{ stash.StashAndKeepIndex, stash.StashIncludingUntrackedFiles, stash.StashStaged, + stash.StashStagedPartialFile, stash.StashUnstaged, status.ClickRepoNameToOpenReposMenu, status.ClickToFocus, |