mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-17 02:56:57 +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`] = `
|
exports[`simple site custom pagination 1`] = `
|
||||||
Array [
|
Array [
|
||||||
|
Array [
|
||||||
|
undefined,
|
||||||
|
Object {
|
||||||
|
"permalink": "/docs/headingAsTitle",
|
||||||
|
"title": "My heading as title",
|
||||||
|
},
|
||||||
|
],
|
||||||
Array [
|
Array [
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
@ -17,7 +24,10 @@ Array [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
Array [
|
Array [
|
||||||
undefined,
|
Object {
|
||||||
|
"permalink": "/docs/doc with space",
|
||||||
|
"title": "Hoo hoo, if this path tricks you...",
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"permalink": "/docs/",
|
"permalink": "/docs/",
|
||||||
"title": "Hello sidebar_label",
|
"title": "Hello sidebar_label",
|
||||||
|
|
|
@ -6,6 +6,7 @@ These sidebar document ids do not exist:
|
||||||
- goku
|
- goku
|
||||||
|
|
||||||
Available document ids are:
|
Available document ids are:
|
||||||
|
- doc with space
|
||||||
- foo/bar
|
- foo/bar
|
||||||
- foo/baz
|
- foo/baz
|
||||||
- headingAsTitle
|
- headingAsTitle
|
||||||
|
@ -241,6 +242,11 @@ Object {
|
||||||
"versions": Array [
|
"versions": Array [
|
||||||
Object {
|
Object {
|
||||||
"docs": Array [
|
"docs": Array [
|
||||||
|
Object {
|
||||||
|
"id": "doc with space",
|
||||||
|
"path": "/docs/doc with space",
|
||||||
|
"sidebar": undefined,
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "foo/bar",
|
"id": "foo/bar",
|
||||||
"path": "/docs/foo/bar",
|
"path": "/docs/foo/bar",
|
||||||
|
@ -326,6 +332,19 @@ Object {
|
||||||
|
|
||||||
exports[`simple website content: data 1`] = `
|
exports[`simple website content: data 1`] = `
|
||||||
Object {
|
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": "{
|
"site-docs-foo-bar-md-8c2.json": "{
|
||||||
\\"unversionedId\\": \\"foo/bar\\",
|
\\"unversionedId\\": \\"foo/bar\\",
|
||||||
\\"id\\": \\"foo/bar\\",
|
\\"id\\": \\"foo/bar\\",
|
||||||
|
@ -811,6 +830,11 @@ Object {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
\\"docs\\": {
|
\\"docs\\": {
|
||||||
|
\\"doc with space\\": {
|
||||||
|
\\"id\\": \\"doc with space\\",
|
||||||
|
\\"title\\": \\"Hoo hoo, if this path tricks you...\\",
|
||||||
|
\\"description\\": \\"\\"
|
||||||
|
},
|
||||||
\\"foo/bar\\": {
|
\\"foo/bar\\": {
|
||||||
\\"id\\": \\"foo/bar\\",
|
\\"id\\": \\"foo/bar\\",
|
||||||
\\"title\\": \\"Bar\\",
|
\\"title\\": \\"Bar\\",
|
||||||
|
@ -902,6 +926,11 @@ Object {
|
||||||
"versions": Array [
|
"versions": Array [
|
||||||
Object {
|
Object {
|
||||||
"docs": Array [
|
"docs": Array [
|
||||||
|
Object {
|
||||||
|
"id": "doc with space",
|
||||||
|
"path": "/docs/doc with space",
|
||||||
|
"sidebar": undefined,
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"id": "foo/bar",
|
"id": "foo/bar",
|
||||||
"path": "/docs/foo/bar",
|
"path": "/docs/foo/bar",
|
||||||
|
@ -1045,6 +1074,14 @@ Array [
|
||||||
},
|
},
|
||||||
"path": "/docs/absoluteSlug",
|
"path": "/docs/absoluteSlug",
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"component": "@theme/DocItem",
|
||||||
|
"exact": true,
|
||||||
|
"modules": Object {
|
||||||
|
"content": "@site/docs/doc with space.md",
|
||||||
|
},
|
||||||
|
"path": "/docs/doc with space",
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"component": "@theme/DocItem",
|
"component": "@theme/DocItem",
|
||||||
"exact": true,
|
"exact": true,
|
||||||
|
|
|
@ -202,6 +202,7 @@ describe('simple site', () => {
|
||||||
'rootResolvedSlug.md',
|
'rootResolvedSlug.md',
|
||||||
'rootTryToEscapeSlug.md',
|
'rootTryToEscapeSlug.md',
|
||||||
'headingAsTitle.md',
|
'headingAsTitle.md',
|
||||||
|
'doc with space.md',
|
||||||
'foo/bar.md',
|
'foo/bar.md',
|
||||||
'foo/baz.md',
|
'foo/baz.md',
|
||||||
'slugs/absoluteSlug.md',
|
'slugs/absoluteSlug.md',
|
||||||
|
|
|
@ -28,6 +28,22 @@ describe('lastUpdate', () => {
|
||||||
expect(typeof timestamp).toBe('number');
|
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 () => {
|
test('non-existing file', async () => {
|
||||||
const consoleMock = jest.spyOn(console, 'error').mockImplementation();
|
const consoleMock = jest.spyOn(console, 'error').mockImplementation();
|
||||||
const nonExistingFileName = '.nonExisting';
|
const nonExistingFileName = '.nonExisting';
|
||||||
|
|
|
@ -43,12 +43,12 @@ export async function getFileLastUpdate(
|
||||||
return null;
|
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,
|
silent: true,
|
||||||
});
|
});
|
||||||
if (result.code !== 0) {
|
if (result.code !== 0) {
|
||||||
throw new Error(
|
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());
|
return getTimestampAndAuthor(result.stdout.trim());
|
||||||
|
|
|
@ -20,6 +20,7 @@ const dogfoodingPluginInstances = [
|
||||||
// Using a symlinked folder as source, test for use-case https://github.com/facebook/docusaurus/issues/3272
|
// Using a symlinked folder as source, test for use-case https://github.com/facebook/docusaurus/issues/3272
|
||||||
// The target folder uses a _ prefix to test against an edge case regarding MDX partials: https://github.com/facebook/docusaurus/discussions/5181#discussioncomment-1018079
|
// The target folder uses a _ prefix to test against an edge case regarding MDX partials: https://github.com/facebook/docusaurus/discussions/5181#discussioncomment-1018079
|
||||||
path: fs.realpathSync('_dogfooding/docs-tests-symlink'),
|
path: fs.realpathSync('_dogfooding/docs-tests-symlink'),
|
||||||
|
showLastUpdateTime: true,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue