From ee7137ee7dbd69d97ad0300afa77b987f54d7aca Mon Sep 17 00:00:00 2001 From: sebastien Date: Thu, 6 Nov 2025 18:45:21 +0100 Subject: [PATCH] cleanup VcsGitAdHoc --- .../docusaurus-utils/src/vcs/vcsGitAdHoc.ts | 31 ++----------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/packages/docusaurus-utils/src/vcs/vcsGitAdHoc.ts b/packages/docusaurus-utils/src/vcs/vcsGitAdHoc.ts index 297bc4f79c..61c6e592f2 100644 --- a/packages/docusaurus-utils/src/vcs/vcsGitAdHoc.ts +++ b/packages/docusaurus-utils/src/vcs/vcsGitAdHoc.ts @@ -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); }, };