misc(plugin-docs): fix Windows test snapshot for git history retrieval (#5905)

* misc(plugin-docs): fix test snapshot

* Fix again
This commit is contained in:
Joshua Chen 2021-11-08 17:09:58 +08:00 committed by GitHub
parent 334b4397e7
commit a835c9bc48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -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();

View file

@ -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) {