From 431e21eb1ba77ffe94c8172fd52e9f28a1462b0e Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Sun, 29 Jun 2025 19:09:52 -0400 Subject: [PATCH] Make sure there is no space after the signature --- web/src/lib/util.ts | 2 +- ...h-multiple-minus-diff-with-signature.patch | 25 +++++++++++++++++++ web/src/test/util.test.ts | 5 ++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 web/src/test/patches/patch-with-multiple-minus-diff-with-signature.patch diff --git a/web/src/lib/util.ts b/web/src/lib/util.ts index ca69d97..9dcba93 100644 --- a/web/src/lib/util.ts +++ b/web/src/lib/util.ts @@ -96,7 +96,7 @@ export function binaryFileDummyDetails(fromFile: string, toFile: string, status: return makeTextDetails(fromFile, toFile, status, fakeContent); } -const fileRegex = /diff --git a\/(\S+) b\/(\S+)\r?\n(?:.+\r?\n)*?(?=-- *\r?\n|diff --git|$)/g; +const fileRegex = /diff --git a\/(\S+) b\/(\S+)\r?\n(?:.+\r?\n)*?(?=-- \r?\n|diff --git|$)/g; function parseHeader( patch: string, diff --git a/web/src/test/patches/patch-with-multiple-minus-diff-with-signature.patch b/web/src/test/patches/patch-with-multiple-minus-diff-with-signature.patch new file mode 100644 index 0000000..ac91b80 --- /dev/null +++ b/web/src/test/patches/patch-with-multiple-minus-diff-with-signature.patch @@ -0,0 +1,25 @@ +From f6ec5d6950dc0e09a72148022353bfd9c7d63cba Mon Sep 17 00:00:00 2001 +From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> +Date: Sun, 29 Jun 2025 19:04:34 -0400 +Subject: [PATCH] test + +--- + test | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test b/test +index 3636ae5..3aa784f 100644 +--- a/test ++++ b/test +@@ -5,6 +5,6 @@ e + + 345 + 123 +-- ++ + e + abc +\ No newline at end of file +-- +2.43.0.windows.1 + diff --git a/web/src/test/util.test.ts b/web/src/test/util.test.ts index be2b3c8..b3151f7 100644 --- a/web/src/test/util.test.ts +++ b/web/src/test/util.test.ts @@ -8,6 +8,11 @@ test("Yield 2 patches from a patch file with signature", () => { expect(splitMultiFilePatch(patch).length).toBe(2); }); +test("Yield 1 patches from a patch file with signature and double -- in the diff", () => { + const patch = loadPatch("patch-with-multiple-minus-diff-with-signature.patch"); + expect(splitMultiFilePatch(patch).length).toBe(1); +}); + test("Yield 2 patches from a patch file without signature", () => { const patch = loadPatch("patch-without-signature.patch"); expect(splitMultiFilePatch(patch).length).toBe(2);