mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-03 00:57:52 +02:00
allow adding whole diff to patch
this was causing a panic add integration test for toggling all commit files
This commit is contained in:
docs/keybindings
pkg
test/integration/patchBuildingToggleAll
expected
.git_keep
COMMIT_EDITMSGFETCH_HEADHEADconfigdescriptionindex
info
logs
objects
18
41
44
4b
4f
68
70
83
98
a5
cf
d2
df
refs
heads
one
two
three
@ -123,6 +123,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
||||
<kbd>o</kbd>: open file
|
||||
<kbd>e</kbd>: edit file
|
||||
<kbd>space</kbd>: toggle file included in patch
|
||||
<kbd>a</kbd>: toggle all files included in patch
|
||||
<kbd>enter</kbd>: enter file to add selected lines to the patch (or toggle directory collapsed)
|
||||
<kbd>`</kbd>: toggle file tree view
|
||||
</pre>
|
||||
|
@ -123,6 +123,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
||||
<kbd>o</kbd>: open bestand
|
||||
<kbd>e</kbd>: verander bestand
|
||||
<kbd>space</kbd>: toggle bestand inbegrepen in patch
|
||||
<kbd>a</kbd>: toggle all files included in patch
|
||||
<kbd>enter</kbd>: enter bestand om geselecteerde regels toe te voegen aan de patch
|
||||
<kbd>`</kbd>: toggle bestandsboom weergave
|
||||
</pre>
|
||||
|
@ -123,6 +123,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
||||
<kbd>o</kbd>: otwórz plik
|
||||
<kbd>e</kbd>: edytuj plik
|
||||
<kbd>space</kbd>: toggle file included in patch
|
||||
<kbd>a</kbd>: toggle all files included in patch
|
||||
<kbd>enter</kbd>: enter file to add selected lines to the patch (or toggle directory collapsed)
|
||||
<kbd>`</kbd>: toggle file tree view
|
||||
</pre>
|
||||
|
@ -123,6 +123,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
|
||||
<kbd>o</kbd>: 打开文件
|
||||
<kbd>e</kbd>: 编辑文件
|
||||
<kbd>space</kbd>: 补丁中包含的切换文件
|
||||
<kbd>a</kbd>: toggle all files included in patch
|
||||
<kbd>enter</kbd>: 输入文件以将所选行添加到补丁中(或切换目录折叠)
|
||||
<kbd>`</kbd>: 切换文件树视图
|
||||
</pre>
|
||||
|
@ -52,6 +52,11 @@ func (self *CommitFilesController) GetKeybindings(opts types.KeybindingsOpts) []
|
||||
Handler: self.checkSelected(self.toggleForPatch),
|
||||
Description: self.c.Tr.LcToggleAddToPatch,
|
||||
},
|
||||
{
|
||||
Key: opts.GetKey(opts.Config.Files.ToggleStagedAll),
|
||||
Handler: self.checkSelected(self.toggleAllForPatch),
|
||||
Description: self.c.Tr.LcToggleAllInPatch,
|
||||
},
|
||||
{
|
||||
Key: opts.GetKey(opts.Config.Universal.GoInto),
|
||||
Handler: self.checkSelected(self.enter),
|
||||
@ -150,7 +155,8 @@ func (self *CommitFilesController) edit(node *filetree.CommitFileNode) error {
|
||||
}
|
||||
|
||||
func (self *CommitFilesController) toggleForPatch(node *filetree.CommitFileNode) error {
|
||||
toggleTheFile := func() error {
|
||||
toggle := func() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.LcUpdatingPatch, func() error {
|
||||
if !self.git.Patch.PatchManager.Active() {
|
||||
if err := self.startPatchManager(); err != nil {
|
||||
return err
|
||||
@ -179,6 +185,7 @@ func (self *CommitFilesController) toggleForPatch(node *filetree.CommitFileNode)
|
||||
}
|
||||
|
||||
return self.c.PostRefreshUpdate(self.context())
|
||||
})
|
||||
}
|
||||
|
||||
if self.git.Patch.PatchManager.Active() && self.git.Patch.PatchManager.To != self.context().GetRefName() {
|
||||
@ -187,12 +194,18 @@ func (self *CommitFilesController) toggleForPatch(node *filetree.CommitFileNode)
|
||||
Prompt: self.c.Tr.DiscardPatchConfirm,
|
||||
HandleConfirm: func() error {
|
||||
self.git.Patch.PatchManager.Reset()
|
||||
return toggleTheFile()
|
||||
return toggle()
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return toggleTheFile()
|
||||
return toggle()
|
||||
}
|
||||
|
||||
func (self *CommitFilesController) toggleAllForPatch(_ *filetree.CommitFileNode) error {
|
||||
// not a fan of type assertions but this will be fixed very soon thanks to generics
|
||||
root := self.context().CommitFileTreeViewModel.Tree().(*filetree.CommitFileNode)
|
||||
return self.toggleForPatch(root)
|
||||
}
|
||||
|
||||
func (self *CommitFilesController) startPatchManager() error {
|
||||
|
@ -275,6 +275,8 @@ type TranslationSet struct {
|
||||
DiscardPatchConfirm string
|
||||
CantPatchWhileRebasingError string
|
||||
LcToggleAddToPatch string
|
||||
LcToggleAllInPatch string
|
||||
LcUpdatingPatch string
|
||||
ViewPatchOptions string
|
||||
PatchOptionsTitle string
|
||||
NoPatchError string
|
||||
@ -846,6 +848,8 @@ func EnglishTranslationSet() TranslationSet {
|
||||
DiscardPatchConfirm: "You can only build a patch from one commit/stash-entry at a time. Discard current patch?",
|
||||
CantPatchWhileRebasingError: "You cannot build a patch or run patch commands while in a merging or rebasing state",
|
||||
LcToggleAddToPatch: "toggle file included in patch",
|
||||
LcToggleAllInPatch: "toggle all files included in patch",
|
||||
LcUpdatingPatch: "updating patch",
|
||||
ViewPatchOptions: "view custom patch options",
|
||||
PatchOptionsTitle: "Patch Options",
|
||||
NoPatchError: "No patch created yet. To start building a patch, use 'space' on a commit file or enter to add specific lines",
|
||||
|
@ -94,8 +94,7 @@ func RunTests(
|
||||
continue
|
||||
}
|
||||
|
||||
fnWrapper(test, func(t *testing.T) error {
|
||||
t.Helper()
|
||||
fnWrapper(test, func(t *testing.T) error { //nolint: thelper
|
||||
speeds := getTestSpeeds(test.Speed, mode, speedEnv)
|
||||
testPath := filepath.Join(testDir, test.Name)
|
||||
actualRepoDir := filepath.Join(testPath, "actual")
|
||||
|
@ -0,0 +1 @@
|
||||
blah
|
@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
@ -0,0 +1,10 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = false
|
||||
logallrefupdates = true
|
||||
ignorecase = true
|
||||
precomposeunicode = true
|
||||
[user]
|
||||
email = CI@example.com
|
||||
name = CI
|
@ -0,0 +1 @@
|
||||
Unnamed repository; edit this file 'description' to name the repository.
|
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/index
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/index
Normal file
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
# 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]
|
||||
# *~
|
||||
.DS_Store
|
@ -0,0 +1,2 @@
|
||||
0000000000000000000000000000000000000000 7028eaec19b2723b62690974057c92ba7d8c1b11 CI <CI@example.com> 1648038005 +1100 commit (initial): first commit
|
||||
7028eaec19b2723b62690974057c92ba7d8c1b11 cf149a94a18c990b2c5cdd0cf15ec4880f51c8b0 CI <CI@example.com> 1648038005 +1100 commit: blah
|
@ -0,0 +1,2 @@
|
||||
0000000000000000000000000000000000000000 7028eaec19b2723b62690974057c92ba7d8c1b11 CI <CI@example.com> 1648038005 +1100 commit (initial): first commit
|
||||
7028eaec19b2723b62690974057c92ba7d8c1b11 cf149a94a18c990b2c5cdd0cf15ec4880f51c8b0 CI <CI@example.com> 1648038005 +1100 commit: blah
|
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/18/0cf8328022becee9aaa2577a8f84ea2b9f3827
Normal file
Binary file not shown.
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/41/05b6da4ccc191a4abd24b1ffac6a2031534c0b
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/41/05b6da4ccc191a4abd24b1ffac6a2031534c0b
Normal file
Binary file not shown.
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/44/eb4bd0e7419049a8e4176945786c20dae60d7c
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/44/eb4bd0e7419049a8e4176945786c20dae60d7c
Normal file
Binary file not shown.
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904
Normal file
Binary file not shown.
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/4f/346f1ad5ba2917da2109e2eaa2f2dfbb86f10f
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/4f/346f1ad5ba2917da2109e2eaa2f2dfbb86f10f
Normal file
Binary file not shown.
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/68/bbd52379d849022495dcfd11b13f2fb3103d37
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/68/bbd52379d849022495dcfd11b13f2fb3103d37
Normal file
Binary file not shown.
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/70/28eaec19b2723b62690974057c92ba7d8c1b11
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/70/28eaec19b2723b62690974057c92ba7d8c1b11
Normal file
Binary file not shown.
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/83/90c32b5e687b97e242da46498b574ace0e1eb5
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/83/90c32b5e687b97e242da46498b574ace0e1eb5
Normal file
Binary file not shown.
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/98/1651deb012f8e684dd306c1f5bf8edd5c3db67
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/98/1651deb012f8e684dd306c1f5bf8edd5c3db67
Normal file
Binary file not shown.
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/a5/bce3fd2565d8f458555a0c6f42d0504a848bd5
Normal file
Binary file not shown.
4
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/cf/149a94a18c990b2c5cdd0cf15ec4880f51c8b0
Normal file
4
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/cf/149a94a18c990b2c5cdd0cf15ec4880f51c8b0
Normal file
@ -0,0 +1,4 @@
|
||||
x��M
|
||||
�@@a�s����AD���HҔ
|
||||
[��9��Ƿx���j��S���i� "=R �]`\�D<F�t����(i�����\`�b��1��2��O[�ӎ����S�T�Mo�ׇ�
|
||||
����ڧ���
|
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/d2/34c5e057fe32c676ea67e8cb38f4625ddaeb54
Normal file
Binary file not shown.
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b
Normal file
BIN
test/integration/patchBuildingToggleAll/expected/.git_keep/objects/df/6b0d2bcc76e6ec0fca20c227104a4f28bac41b
Normal file
Binary file not shown.
@ -0,0 +1 @@
|
||||
cf149a94a18c990b2c5cdd0cf15ec4880f51c8b0
|
@ -0,0 +1 @@
|
||||
test3
|
1
test/integration/patchBuildingToggleAll/recording.json
Normal file
1
test/integration/patchBuildingToggleAll/recording.json
Normal file
@ -0,0 +1 @@
|
||||
{"KeyEvents":[{"Timestamp":624,"Mod":0,"Key":259,"Ch":0},{"Timestamp":813,"Mod":0,"Key":259,"Ch":0},{"Timestamp":1216,"Mod":0,"Key":13,"Ch":13},{"Timestamp":1841,"Mod":0,"Key":256,"Ch":97},{"Timestamp":2456,"Mod":0,"Key":258,"Ch":0},{"Timestamp":2624,"Mod":0,"Key":258,"Ch":0},{"Timestamp":2841,"Mod":0,"Key":256,"Ch":32},{"Timestamp":3600,"Mod":2,"Key":16,"Ch":16},{"Timestamp":4795,"Mod":0,"Key":258,"Ch":0},{"Timestamp":5193,"Mod":0,"Key":258,"Ch":0},{"Timestamp":5696,"Mod":0,"Key":13,"Ch":13},{"Timestamp":7345,"Mod":0,"Key":256,"Ch":113}],"ResizeEvents":[{"Timestamp":0,"Width":272,"Height":74}]}
|
23
test/integration/patchBuildingToggleAll/setup.sh
Normal file
23
test/integration/patchBuildingToggleAll/setup.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $1
|
||||
|
||||
git init
|
||||
|
||||
git config user.email "CI@example.com"
|
||||
git config user.name "CI"
|
||||
|
||||
git commit --allow-empty -m "first commit"
|
||||
|
||||
mkdir -p one/two/three
|
||||
echo test1 > one/two/three/file1
|
||||
echo test2 > one/two/three/file2
|
||||
echo test3 > one/two/three/file3
|
||||
echo test4 > one/two/three/file4
|
||||
echo test5 > one/two/file1
|
||||
echo test6 > one/two/file2
|
||||
|
||||
git add .
|
||||
git commit -m "blah"
|
1
test/integration/patchBuildingToggleAll/test.json
Normal file
1
test/integration/patchBuildingToggleAll/test.json
Normal file
@ -0,0 +1 @@
|
||||
{ "description": "messing with our patch building flow in both flat and tree view", "speed": 10 }
|
Reference in New Issue
Block a user