Repository navigation
Skip unchanged git marketplaces and fetch only the catalog on refresh - #8128
Merged
Merged
Conversation
materializeGit cloned the whole repository on every add and every refresh of a git: marketplace, checked out the full tree, and deleted .git. The refresh now resolves the ref with ls-remote first; when it still points at the stored commit the stored catalog and icons are reused without touching the repository. When the ref moved, the commit is fetched with --depth 1 --filter=blob:none into a cone-mode sparse checkout of the repository root (plus the icon directories the manifest names) or of the selected subdirectory. Anything the fast path cannot do falls back to the previous full clone.
The sparse checkout only holds the repository root files (or the selected subdirectory) and the icon directories. A marketplace.json, subdirectory, or icon file that is a symlink to another path in the repository then pointed outside that tree, so add and refresh failed or dropped the icon where a full clone succeeded. Check every path the catalog read uses and disable the sparse checkout when one crosses a symlink. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Human comments
Related to #7911 and #8116, this PR speeds up adding/updating git-hosted marketplaces, which can be painfully slow.
What was wrong
materializeGitinapps/server/src/services/plugin-catalog/marketplace-source.tsrangit clone --no-checkout <url>with no depth or filter, resolved the ref withrev-parse, checked out the whole tree, and deleted.git— on everybb marketplace add, every manual refresh, and every periodic refresh, without ever comparing the ref against the storedsourceGitCommit. For a marketplace monorepo with a long history that is ~87 s of download per refresh to read a 346 KBmarketplace.jsonand 152 KB of icons. #7911 fixed the same clone for plugin installs; the marketplace path had its own. Fixes #8127.What changed
marketplace-source.ts:materializeGitfirst resolves the ref withresolveGitRef(onels-remote, the same resolver plugin installs use). If it resolves to the stored commit, the stored catalog is returned asunchanged: truewith no checkout, like the https path does on a 304. If the ref moved (or there is no stored commit), the commit is fetched withgit init+fetch --depth 1 --no-tags --filter=blob:none origin <sha>into a cone-mode sparse checkout: for a root marketplace,sparse-checkout set --cone(repository-root files only), then after readingmarketplace.jsonsparse-checkout addof the directories its local icons live in; for asubdirectorymarketplace, the subdirectory itself. The manifest and icons are then read exactly as before. Ifls-remotecannot resolve the ref (for exampleorigin/<branch>, which the existingrev-parsefallback accepts), the server refuses the fetch, the manifest, the subdirectory, or a local icon path crosses a symlink (whose target may lie outside the sparse tree),sparse-checkout addfails, or an icon directory or the subdirectory contains sparse-pattern characters, the code falls back to the previous full clone + checkout (sparse-checkout disablewhere a sparse tree already exists), so the caller sees the same tree a full clone would. Servers that do not advertise partial clone ignore--filterwith a warning and the sparse working tree still applies.marketplace-icons.ts:onlyMissingnow also reuses cached local icons whose source path is unchanged, and skips local icons that are not cached, so an unchanged git refresh never reads from a checkout that was not made. Local icons only occur forgit:andpath:sources;path:is neverunchanged, and at the same commit the files are identical. Remote icons behave as before.plugin-catalog-service.ts: the refresh passesrow.sourceGitCommitintocached. The add path passescached: nulland takes the sparse-fetch path. A stored catalog that fails to parse is re-read from the repository with a warning rather than failing the refresh.How you verified
refreshes an unchanged ref from the stored catalog without fetching the repository(third-party-marketplaces.test.ts): afteraddMarketplace, deletes the fixture repository's loose objects sols-remotestill answers but any clone or fetch fails, then assertsrefreshMarketplacesreturnsok: truewith the same commit, the stored icon's content hash is unchanged, no warnings were emitted, and the staging directory is empty. Fails onmain(fatal: … nonexistent object).fetches only the catalog and its icons when the ref moved(root) andfetches only the subdirectory when the ref moved(subdirectory): serve the fixture overfile://through aninsteadOfrewrite withuploadpack.allowFilter=true, commit a new catalog (root case: with a second icon in a nested directory) plusplugins/alpha/dist/index.js, delete that blob's object, assert thatgit cloneof the repository fails withpossible repository corruption, and assert the refresh succeeds with the new commit, both entries and both icons. Fail onmain(the full clone needs the missing blob).reads the catalog when %scases (POSIX):marketplace.json, the subdirectory, an icon file, and theiconsdirectory each a symlink to another path in the repository. The first three failed with the sparse checkout before the symlink check (ENOENT … marketplace.json,not a directory in the repository, icon dropped with a warning); all four matchmain.reads the selected catalog commit for ref %scases still pass, includingorigin/catalog-next, whichls-remotecannot resolve and which now exercises the full-clone fallback, andcatalog-release, an annotated tag thatresolveGitRefpeels.pnpm exec turbo run test --filter=@bb/server -- test/services/plugin-catalog/: 171 passed (9 files).test/services/plugins/plugin-install.test.tsandplugin-update.test.ts: 104 passed.turbo run typecheck --filter=@bb/server: clean.oxlinton the touched files reports only thenode:fs/promisesimport restriction already present onmain.createPluginCatalogServiceagainst the marketplace monorepo in Git marketplace refresh clones the whole repository even when the ref has not moved #8127 (89 entries, 39 icons stored, identical warnings before and after):addMarketplace87.05 s → 3.54 s;refreshMarketplaceswith the ref unchanged 87.72 s → 0.75 s.Fixes #8127