mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 00:57:53 +02:00
fix(content-docs): quotify path when retrieving git history (#6202)
* fix(content-docs): quotify path when retrieving git history * Enable last update in dogfooding
This commit is contained in:
parent
7fcadd0c36
commit
3195e7feed
7 changed files with 69 additions and 3 deletions
|
@ -0,0 +1 @@
|
|||
# Hoo hoo, if this path tricks you...
|
|
@ -2,6 +2,13 @@
|
|||
|
||||
exports[`simple site custom pagination 1`] = `
|
||||
Array [
|
||||
Array [
|
||||
undefined,
|
||||
Object {
|
||||
"permalink": "/docs/headingAsTitle",
|
||||
"title": "My heading as title",
|
||||
},
|
||||
],
|
||||
Array [
|
||||
undefined,
|
||||
undefined,
|
||||
|
@ -17,7 +24,10 @@ Array [
|
|||
},
|
||||
],
|
||||
Array [
|
||||
undefined,
|
||||
Object {
|
||||
"permalink": "/docs/doc with space",
|
||||
"title": "Hoo hoo, if this path tricks you...",
|
||||
},
|
||||
Object {
|
||||
"permalink": "/docs/",
|
||||
"title": "Hello sidebar_label",
|
||||
|
|
|
@ -6,6 +6,7 @@ These sidebar document ids do not exist:
|
|||
- goku
|
||||
|
||||
Available document ids are:
|
||||
- doc with space
|
||||
- foo/bar
|
||||
- foo/baz
|
||||
- headingAsTitle
|
||||
|
@ -241,6 +242,11 @@ Object {
|
|||
"versions": Array [
|
||||
Object {
|
||||
"docs": Array [
|
||||
Object {
|
||||
"id": "doc with space",
|
||||
"path": "/docs/doc with space",
|
||||
"sidebar": undefined,
|
||||
},
|
||||
Object {
|
||||
"id": "foo/bar",
|
||||
"path": "/docs/foo/bar",
|
||||
|
@ -326,6 +332,19 @@ Object {
|
|||
|
||||
exports[`simple website content: data 1`] = `
|
||||
Object {
|
||||
"site-docs-doc-with-space-md-e90.json": "{
|
||||
\\"unversionedId\\": \\"doc with space\\",
|
||||
\\"id\\": \\"doc with space\\",
|
||||
\\"title\\": \\"Hoo hoo, if this path tricks you...\\",
|
||||
\\"description\\": \\"\\",
|
||||
\\"source\\": \\"@site/docs/doc with space.md\\",
|
||||
\\"sourceDirName\\": \\".\\",
|
||||
\\"slug\\": \\"/doc with space\\",
|
||||
\\"permalink\\": \\"/docs/doc with space\\",
|
||||
\\"tags\\": [],
|
||||
\\"version\\": \\"current\\",
|
||||
\\"frontMatter\\": {}
|
||||
}",
|
||||
"site-docs-foo-bar-md-8c2.json": "{
|
||||
\\"unversionedId\\": \\"foo/bar\\",
|
||||
\\"id\\": \\"foo/bar\\",
|
||||
|
@ -811,6 +830,11 @@ Object {
|
|||
]
|
||||
},
|
||||
\\"docs\\": {
|
||||
\\"doc with space\\": {
|
||||
\\"id\\": \\"doc with space\\",
|
||||
\\"title\\": \\"Hoo hoo, if this path tricks you...\\",
|
||||
\\"description\\": \\"\\"
|
||||
},
|
||||
\\"foo/bar\\": {
|
||||
\\"id\\": \\"foo/bar\\",
|
||||
\\"title\\": \\"Bar\\",
|
||||
|
@ -902,6 +926,11 @@ Object {
|
|||
"versions": Array [
|
||||
Object {
|
||||
"docs": Array [
|
||||
Object {
|
||||
"id": "doc with space",
|
||||
"path": "/docs/doc with space",
|
||||
"sidebar": undefined,
|
||||
},
|
||||
Object {
|
||||
"id": "foo/bar",
|
||||
"path": "/docs/foo/bar",
|
||||
|
@ -1045,6 +1074,14 @@ Array [
|
|||
},
|
||||
"path": "/docs/absoluteSlug",
|
||||
},
|
||||
Object {
|
||||
"component": "@theme/DocItem",
|
||||
"exact": true,
|
||||
"modules": Object {
|
||||
"content": "@site/docs/doc with space.md",
|
||||
},
|
||||
"path": "/docs/doc with space",
|
||||
},
|
||||
Object {
|
||||
"component": "@theme/DocItem",
|
||||
"exact": true,
|
||||
|
|
|
@ -202,6 +202,7 @@ describe('simple site', () => {
|
|||
'rootResolvedSlug.md',
|
||||
'rootTryToEscapeSlug.md',
|
||||
'headingAsTitle.md',
|
||||
'doc with space.md',
|
||||
'foo/bar.md',
|
||||
'foo/baz.md',
|
||||
'slugs/absoluteSlug.md',
|
||||
|
|
|
@ -28,6 +28,22 @@ describe('lastUpdate', () => {
|
|||
expect(typeof timestamp).toBe('number');
|
||||
});
|
||||
|
||||
test('existing test file with spaces in path', async () => {
|
||||
const filePathWithSpace = path.join(
|
||||
__dirname,
|
||||
'__fixtures__/simple-site/docs/doc with space.md',
|
||||
);
|
||||
const lastUpdateData = await getFileLastUpdate(filePathWithSpace);
|
||||
expect(lastUpdateData).not.toBeNull();
|
||||
|
||||
const {author, timestamp} = lastUpdateData;
|
||||
expect(author).not.toBeNull();
|
||||
expect(typeof author).toBe('string');
|
||||
|
||||
expect(timestamp).not.toBeNull();
|
||||
expect(typeof timestamp).toBe('number');
|
||||
});
|
||||
|
||||
test('non-existing file', async () => {
|
||||
const consoleMock = jest.spyOn(console, 'error').mockImplementation();
|
||||
const nonExistingFileName = '.nonExisting';
|
||||
|
|
|
@ -43,12 +43,12 @@ export async function getFileLastUpdate(
|
|||
return null;
|
||||
}
|
||||
|
||||
const result = shell.exec(`git log -1 --format=%ct,%an ${filePath}`, {
|
||||
const result = shell.exec(`git log -1 --format=%ct,%an "${filePath}"`, {
|
||||
silent: true,
|
||||
});
|
||||
if (result.code !== 0) {
|
||||
throw new Error(
|
||||
`Retrieval of git history failed at ${filePath} with exit code ${result.code}: ${result.stderr}`,
|
||||
`Retrieval of git history failed at "${filePath}" with exit code ${result.code}: ${result.stderr}`,
|
||||
);
|
||||
}
|
||||
return getTimestampAndAuthor(result.stdout.trim());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue