Repository navigation
Find commit that adds a file without git log --follow - #2382
Krrishkumar125 wants to merge 1 commit into
Conversation
git 2.56 made --follow much slower in blobless clones because it does rename detection against every file in the parent tree, once per parent of a merge. For a monorepo with many pending changesets this can make changeset version take many minutes. Find the add with renames off and check for a rename only on that single commit, walking the chain back when there is one, which returns the same commit as --follow did.
👷 Deploy request for changesets pending review.Visit the deploys page to approve it
|
🦋 Changeset detectedLatest commit: e9b4d6b The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2382 +/- ##
==========================================
+ Coverage 87.47% 87.53% +0.05%
==========================================
Files 78 78
Lines 2971 2985 +14
Branches 851 858 +7
==========================================
+ Hits 2599 2613 +14
Misses 337 337
Partials 35 35 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…o the release job does not run out of memory (#113) On git 2.56 each lookup in this repository takes about 290 MB, and changesets runs one for each pending changeset at once. The patch of @changesets/git follows changesets/changesets#2382. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #2364.
What
getCommitsThatAddFilesin@changesets/gitusedgit log --diff-filter=AC --followto find the commit that added each changeset file.--followturns on rename detection against every file in the parent tree. On git 2.56 that work also runs for each parent of a merge commit, and in a blobless clone git lazily fetches those blobs to do the comparison. Running it once per changeset means a repo with many pending changesets can pull in most of the tree, andchangeset versioncan take many minutes in CI.This replaces
--followwith a two step lookup:git log --diff-filter=A --no-renames.git diff --name-status -Mbetween that commit and its parent, then keep walking back under the old name.The returned commit is the same one
--followreturned.Why
--follow's cost is rename detection across the whole parent tree, repeated per changeset. The rename only matters at the one commit that added the file, so checking there is enough and avoids the tree wide scan and the lazy blob fetches.Tests
getCommitsThatAddFilestests pass, including the rename, rename-then-tweak, exact-copy and highly-similar cases.a.jstob.jstoc.js) resolving back to the original add commit from a depth 1 shallow clone.Run with
pnpm vitest run packages/git/src/index.test.ts(37 passed).