From 1cea63a93f62e2c7a57f1355bc1db497e692a4bb Mon Sep 17 00:00:00 2001 From: sebastien Date: Fri, 5 Apr 2024 12:50:06 +0200 Subject: [PATCH] Add useful comments --- packages/docusaurus-utils/src/gitUtils.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-utils/src/gitUtils.ts b/packages/docusaurus-utils/src/gitUtils.ts index 419fcb85e56c..39a3ad754a0c 100644 --- a/packages/docusaurus-utils/src/gitUtils.ts +++ b/packages/docusaurus-utils/src/gitUtils.ts @@ -107,9 +107,12 @@ export async function getFileCommitDate( ); } - const format = includeAuthor ? 'RESULT:%ct,%an' : 'RESULT:%ct'; + // We add a "RESULT:" prefix to make parsing easier + // See why: https://github.com/facebook/docusaurus/pull/10022 + const resultFormat = includeAuthor ? 'RESULT:%ct,%an' : 'RESULT:%ct'; + const args = [ - `--format=${format}`, + `--format=${resultFormat}`, '--max-count=1', age === 'oldest' ? '--follow --diff-filter=A' : undefined, ] @@ -144,6 +147,8 @@ export async function getFileCommitDate( ); } + // We only parse the output line starting with our "RESULT:" prefix + // See why https://github.com/facebook/docusaurus/pull/10022 const regex = includeAuthor ? /(?:^|\n)RESULT:(?\d+),(?.+)(?:$|\n)/ : /(?:^|\n)RESULT:(?\d+)(?:$|\n)/;