perf: make a single git call for timestamps instead of calling it for each file #4958
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
--- Autogenerated ---
This pull request optimizes how git timestamps are retrieved and cached for markdown files, improving both performance and reliability of the sitemap generation process. The main changes include introducing a new bulk caching function for git timestamps, updating related imports, and ensuring consistent path handling.
Git Timestamp Caching Improvements:
cacheAllGitTimestamps
insrc/node/utils/getGitTimestamp.ts
to efficiently pre-fetch and cache git timestamps for all markdown files in a repository using a single git command. This reduces the number of individual git calls during site generation.getGitTimestamp
function to use the cached values and improved its logic for parsing git output and handling file paths.Integration with Build and Plugin System:
src/node/plugin.ts
, importedcacheAllGitTimestamps
and invoked it in the VitePress plugin setup to pre-resolve timestamps for all markdown files when thelastUpdated
feature is enabled. [1] [2]Path Handling Consistency:
slash
utility when retrieving git timestamps, both insrc/node/build/generateSitemap.ts
andsrc/node/utils/getGitTimestamp.ts
, to prevent mismatches and improve cross-platform compatibility. [1] [2] [3]