Skip to content

Commit

Permalink
misc(plugin-docs): fix Windows test snapshot for git history retrieval (
Browse files Browse the repository at this point in the history
#5905)

* misc(plugin-docs): fix test snapshot

* Fix again
  • Loading branch information
Josh-Cena authored Nov 8, 2021
1 parent 334b439 commit a835c9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('lastUpdate', () => {
expect(await getFileLastUpdate(nonExistingFilePath)).toBeNull();
expect(consoleMock).toHaveBeenCalledTimes(1);
expect(consoleMock.mock.calls[0][0].message).toContain(
`fatal: ambiguous argument '${nonExistingFilePath}': unknown revision or path not in the working tree.`,
' with exit code 128',
);
expect(await getFileLastUpdate(null)).toBeNull();
expect(await getFileLastUpdate(undefined)).toBeNull();
Expand Down
6 changes: 4 additions & 2 deletions packages/docusaurus-plugin-content-docs/src/lastUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ export async function getFileLastUpdate(
}

const result = shell.exec(`git log -1 --format=%ct,%an ${filePath}`);
if (result.stderr) {
throw new Error(result.stderr);
if (result.code !== 0) {
throw new Error(
`Retrieval of git history failed at ${filePath} with exit code ${result.code}: ${result.stderr}`,
);
}
return getTimestampAndAuthor(result.stdout.trim());
} catch (error) {
Expand Down

0 comments on commit a835c9b

Please sign in to comment.