fix: reuse locked git commit for source deps without rev#6096
Closed
wolfv wants to merge 1 commit into
Closed
Conversation
A dep declared as `kelvin = { git = "https://..." }` (no `rev`) used to
re-fetch the remote's default branch on every command. The lock file
already stores the resolved commit, but the install/run path goes
through `pin_and_checkout` with `GitReference::DefaultBranch`, which
leaves `GitUrl.precise` unset and skips the no-fetch fast path in
`pixi_git::source::GitSource::fetch`.
Seed the dispatcher's `GitResolver` with every locked git source at
the start of the update flow. The resolver maps `(url, ref)` to the
resolved sha, so the next `pin_and_checkout` for the same `(url, ref)`
pair picks up the precise commit and the fast path engages.
`pixi update` builds its own dispatcher off an unlocked lock file, so
it remains unaffected and still re-resolves mutable refs as expected.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
|
I think #6094 might already solve this issue. The problem was that we didnt populate |
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.
Summary
Closes #6091.
A conda source dep declared as
{ git = "https://..." }(norev) re-fetched the remote's default branch on every command. The fix is a 5-line helper that seeds the dispatcher'sGitResolverwith the locked commits, so the existing no-fetch fast path engages.Why this was happening
The "skip fetch" fast path in
pixi_git::source::GitSource::fetchonly fires whenGitUrl.preciseisSome(sha):rev = "<40-char sha>": parsed intoGitReference::FullCommit;GitUrl::from_referenceauto-fillspreciseviareference.as_sha(). Fast path hits.rev: parsed intoGitReference::DefaultBranch;as_sha()returnsNone;precisestays unset. Fast path skipped — even though the lock file does store the resolved sha.GitResolveralready keeps an in-process(url, ref) → shacache thatfetch()consults before going to the network. It just wasn't seeded from the lock file.What this change does
seed_git_resolver_from_lock_filewalks every conda source package in the lock file, parses anygit+...#<sha>URL viaLockedGitUrl::to_pinned_git_spec, and inserts(repository_url, requested_reference) → shainto the dispatcher'sGitResolver. It's called once, right after the dispatcher is built inWorkspace::update_lock_file.After seeding,
pin_and_checkoutfor{ git = "url" }(norev):GitUrl::from_reference(url, DefaultBranch)— precise unsetGitResolver::fetchlooks upRepositoryReference { url, DefaultBranch }, finds the seeded sha, callsurl.with_precise(sha)GitSource::fetchseesprecise = Some(sha), finds the commit in the local db, returns without touching the networkScope / safety
pixi updateandpixi addbuild their own dispatcher off an unlocked lock file (unlock_packages/UpdateContext::builder), so seeding does not pin stale refs there — those flows continue to re-resolve mutable refs as expected. The seed only affectsupdate_lock_file, which is the entry point forpixi run,pixi install,pixi shell, etc.If the user changes a manifest spec (e.g. adds a
branch = "..."or changes the URL),PinnedGitCheckout::matches_source_speccorrectly returns false and a re-lock fires; the seeded entry for the old(url, ref)pair is harmless because the new pair isn't in the map.Test plan
test_seed_git_resolver_seeds_default_branch_sourcecovering the default-branch case end-to-end (build a lock file with a git source pin, seed an emptyGitResolver, assertresolver.precise(...)returns the locked sha).cargo check --workspace --testscargo clippy -p pixi_core -p pixi_command_dispatcher --tests --libkelvin = { git = "https://github.com/bgreni/Kelvin" }confirm thatpixi run <task>no longer fetches after the first install.🤖 Generated with Claude Code