1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-23 12:18:51 +02:00

Concatenate patches to apply them all at once

This fixes the problem that patching would stop at the first file that has a
conflict. We always want to patch all files.

Also, it's faster for large patches, and the code is a little bit simpler too.
This commit is contained in:
Stefan Haller 2023-02-23 22:51:49 +01:00
parent 4ca012dbfb
commit a68cd6af9c
2 changed files with 6 additions and 9 deletions

View File

@ -245,6 +245,8 @@ func (p *PatchManager) GetFileIncLineIndices(filename string) ([]int, error) {
}
func (p *PatchManager) ApplyPatches(reverse bool) error {
patch := ""
applyFlags := []string{"index", "3way"}
if reverse {
applyFlags = append(applyFlags, "reverse")
@ -255,16 +257,10 @@ func (p *PatchManager) ApplyPatches(reverse bool) error {
continue
}
patch := p.RenderPatchForFile(filename, true, reverse)
if patch != "" {
err := p.applyPatch(patch, applyFlags...)
if err != nil {
return err
}
}
patch += p.RenderPatchForFile(filename, true, reverse)
}
return nil
return p.applyPatch(patch, applyFlags...)
}
// clears the patch

View File

@ -52,7 +52,7 @@ var ApplyInReverseWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Alert().
Title(Equals("Error")).
Content(Contains("Applied patch to 'file1' with conflicts.").
DoesNotContain("Applied patch to 'file2' cleanly.")).
Contains("Applied patch to 'file2' cleanly.")).
Confirm()
t.Views().Files().
@ -79,6 +79,7 @@ var ApplyInReverseWithConflict = NewIntegrationTest(NewIntegrationTestArgs{
Focus().
Lines(
Contains("M").Contains("file1").IsSelected(),
Contains("M").Contains("file2"),
)
t.Views().Main().