From 1015bac9412c27446d106981a32fb41b8bfd7c3b Mon Sep 17 00:00:00 2001 From: Josh-Cena Date: Mon, 8 Nov 2021 15:46:40 +0800 Subject: [PATCH 1/2] misc(plugin-docs): fix test snapshot --- .../src/__tests__/lastUpdate.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/lastUpdate.test.ts b/packages/docusaurus-plugin-content-docs/src/__tests__/lastUpdate.test.ts index 5c8f07e0e512..335a8d2ad79e 100644 --- a/packages/docusaurus-plugin-content-docs/src/__tests__/lastUpdate.test.ts +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/lastUpdate.test.ts @@ -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.`, + 'unknown revision or path not in the working tree.', ); expect(await getFileLastUpdate(null)).toBeNull(); expect(await getFileLastUpdate(undefined)).toBeNull(); From 593c16e3dc47001f0379721c9af23f3ff8df7bb5 Mon Sep 17 00:00:00 2001 From: Josh-Cena Date: Mon, 8 Nov 2021 16:48:45 +0800 Subject: [PATCH 2/2] Fix again --- .../src/__tests__/lastUpdate.test.ts | 2 +- packages/docusaurus-plugin-content-docs/src/lastUpdate.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/lastUpdate.test.ts b/packages/docusaurus-plugin-content-docs/src/__tests__/lastUpdate.test.ts index 335a8d2ad79e..36324d16c025 100644 --- a/packages/docusaurus-plugin-content-docs/src/__tests__/lastUpdate.test.ts +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/lastUpdate.test.ts @@ -40,7 +40,7 @@ describe('lastUpdate', () => { expect(await getFileLastUpdate(nonExistingFilePath)).toBeNull(); expect(consoleMock).toHaveBeenCalledTimes(1); expect(consoleMock.mock.calls[0][0].message).toContain( - 'unknown revision or path not in the working tree.', + ' with exit code 128', ); expect(await getFileLastUpdate(null)).toBeNull(); expect(await getFileLastUpdate(undefined)).toBeNull(); diff --git a/packages/docusaurus-plugin-content-docs/src/lastUpdate.ts b/packages/docusaurus-plugin-content-docs/src/lastUpdate.ts index a5de58da6aed..3154d8843e12 100644 --- a/packages/docusaurus-plugin-content-docs/src/lastUpdate.ts +++ b/packages/docusaurus-plugin-content-docs/src/lastUpdate.ts @@ -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) {