Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(utils): getFileCommitDate should support log.showSignature=true #10022

Merged
merged 3 commits into from
Apr 5, 2024

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Apr 5, 2024

Motivation

When the user shows signatures by default in his config (git config log.showSignature true), getFileCommitDate fails to parse the result because of the extra lines being printed, and the regexp to extract it not being able to process the command output due to the signature lines.

Problem reported here: #9954 (comment)

CleanShot 2024-04-05 at 12 28 57@2x

I'm now adding a RESULT: prefix so that we only attempt to parse the correct lines, ignore all the others.

Also, we don't need signatures to get the result, so I'm also passing git -c log.showSignature=false log as an option so that the command can execute faster. If users have signatures turned on, we don't want this function to be 3x slower.

hyperfine --runs 50 'git -c log.showSignature=true log --format=RESULT:%ct,%an --max-count=1 -- CHANGELOG.md'
Benchmark 1: git -c log.showSignature=true log --format=RESULT:%ct,%an --max-count=1 -- CHANGELOG.md
  Time (mean ± σ):       9.7 ms ±   1.1 ms    [User: 4.3 ms, System: 3.7 ms]
  Range (min … max):     8.0 ms …  12.5 ms    50 runs

hyperfine --runs 50 'git -c log.showSignature=false log --format=RESULT:%ct,%an --max-count=1 -- CHANGELOG.md'
Benchmark 1: git -c log.showSignature=false log --format=RESULT:%ct,%an --max-count=1 -- CHANGELOG.md
  Time (mean ± σ):       3.5 ms ±   0.2 ms    [User: 1.8 ms, System: 1.4 ms]
  Range (min … max):     3.0 ms …   4.2 ms    50 runs

Note: I also considered the following command but it's not faster and won't work well with the "age: 'oldest'` option:

git rev-list --no-commit-header --max-count=1 --format=%ct,%an HEAD -- CHANGELOG.md

Test Plan

Unit tests

@slorber slorber requested a review from Josh-Cena as a code owner April 5, 2024 10:47
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 5, 2024
@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Apr 5, 2024
packages/docusaurus-utils/src/gitUtils.ts Dismissed Show dismissed Hide dismissed
Copy link

netlify bot commented Apr 5, 2024

[V2]

Name Link
🔨 Latest commit f3b364b
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/660fd6b58b80050008444393
😎 Deploy Preview https://deploy-preview-10022--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Apr 5, 2024

[V2]

Name Link
🔨 Latest commit 1cea63a
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/660fd7655469680007905140
😎 Deploy Preview https://deploy-preview-10022--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented Apr 5, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 68 🟢 98 🟢 96 🟢 100 🟠 88 Report
/docs/installation 🟠 65 🟢 96 🟢 100 🟢 100 🟠 88 Report
/docs/category/getting-started 🟠 75 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog 🟠 70 🟢 100 🟢 100 🟢 90 🟠 88 Report
/blog/preparing-your-site-for-docusaurus-v3 🟠 63 🟢 96 🟢 100 🟢 100 🟠 88 Report
/blog/tags/release 🟠 69 🟢 100 🟢 100 🟠 80 🟠 88 Report
/blog/tags 🟠 75 🟢 100 🟢 100 🟢 90 🟠 88 Report

Copy link

github-actions bot commented Apr 5, 2024

Size Change: 0 B

Total Size: 1.05 MB

ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 91.2 kB
website/build/assets/css/styles.********.css 114 kB
website/build/assets/js/main.********.js 810 kB
website/build/index.html 38 kB

compressed-size-action

@slorber slorber merged commit 6e1364b into main Apr 5, 2024
31 checks passed
@slorber slorber deleted the slorber/improve-getFileCommitDate-robustness branch April 5, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants