mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
cleanup VcsGitAdHoc
This commit is contained in:
parent
2491491328
commit
ee7137ee7d
|
|
@ -5,12 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {
|
||||
FileNotTrackedError,
|
||||
getFileCommitDate,
|
||||
GitNotFoundError,
|
||||
getGitLastUpdate,
|
||||
} from './gitUtils';
|
||||
import {getGitLastUpdate, getGitCreation} from './gitUtils';
|
||||
import type {VcsConfig} from '@docusaurus/types';
|
||||
|
||||
/**
|
||||
|
|
@ -26,32 +21,10 @@ export const VcsGitAdHoc: VcsConfig = {
|
|||
},
|
||||
|
||||
getFileCreationInfo: async (filePath: string) => {
|
||||
try {
|
||||
return await getFileCommitDate(filePath, {
|
||||
age: 'oldest',
|
||||
includeAuthor: true,
|
||||
});
|
||||
} catch (error) {
|
||||
// TODO Docusaurus v4: remove this logic using exceptions for control flow
|
||||
// We add this logic to make it similar to getLastUpdate() that also
|
||||
// returns null in these case and does not throw
|
||||
if (error instanceof GitNotFoundError) {
|
||||
return null;
|
||||
} else if (error instanceof FileNotTrackedError) {
|
||||
return null;
|
||||
} else {
|
||||
throw new Error(
|
||||
`An error occurred when trying to get the last update date`,
|
||||
{cause: error},
|
||||
);
|
||||
}
|
||||
}
|
||||
return getGitCreation(filePath);
|
||||
},
|
||||
|
||||
getFileLastUpdateInfo: async (filePath: string) => {
|
||||
// TODO non-ideal integration but good enough for now
|
||||
// This keeps this new VscConfig system retro-compatible with the existing
|
||||
// historical Docusaurus behavior based on Git
|
||||
return getGitLastUpdate(filePath);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue