From 8a3118d246ea7fb327cb2a876c9324ac5502ddd5 Mon Sep 17 00:00:00 2001 From: Lee Newson Date: Thu, 14 Mar 2024 10:29:06 +1000 Subject: [PATCH] fix: stat diff summary performance --- .changeset/six-cherries-grab.md | 5 +++++ simple-git/src/lib/parsers/parse-diff-summary.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/six-cherries-grab.md diff --git a/.changeset/six-cherries-grab.md b/.changeset/six-cherries-grab.md new file mode 100644 index 00000000..a932b89d --- /dev/null +++ b/.changeset/six-cherries-grab.md @@ -0,0 +1,5 @@ +--- +"simple-git": patch +--- + +Fixed a performance issue when parsing stat diff summaries diff --git a/simple-git/src/lib/parsers/parse-diff-summary.ts b/simple-git/src/lib/parsers/parse-diff-summary.ts index 45d1bb27..08b0911e 100644 --- a/simple-git/src/lib/parsers/parse-diff-summary.ts +++ b/simple-git/src/lib/parsers/parse-diff-summary.ts @@ -6,7 +6,7 @@ import { asNumber, LineParser, orVoid, parseStringResponse } from '../utils'; const statParser = [ new LineParser( - /(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/, + /^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/, (result, [file, changes, alterations = '']) => { result.files.push({ file: file.trim(), @@ -18,7 +18,7 @@ const statParser = [ } ), new LineParser( - /(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/, + /^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/, (result, [file, before, after]) => { result.files.push({ file: file.trim(),