Skip to content

Commit

Permalink
Add useful comments
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Apr 5, 2024
1 parent f3b364b commit 1cea63a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/docusaurus-utils/src/gitUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
Expand Down Expand Up @@ -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:(?<timestamp>\d+),(?<author>.+)(?:$|\n)/
: /(?:^|\n)RESULT:(?<timestamp>\d+)(?:$|\n)/;
Expand Down

0 comments on commit 1cea63a

Please sign in to comment.