Skip to content

Commit 8f936df

Browse files
authored
fix: include precise in CheckoutGit dedup key (#6094)
1 parent c4dc9aa commit 8f936df

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

crates/pixi_command_dispatcher/tests/integration/snapshots/integration__simple_test.snap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ Pixi solve (test@[PLATFORM])
66
├── Git Checkout (file://[LOCAL_GIT_REPO]#[GIT_HASH])
77
├── Source metadata (foobar-desktop @ git+file://[LOCAL_GIT_REPO]?subdirectory=recipe&rev=[GIT_REF]#[GIT_HASH])
88
│ ├── Build backend metadata (git+file://[LOCAL_GIT_REPO]?subdirectory=recipe&rev=[GIT_REF]#[GIT_HASH])
9+
│ │ ├── Git Checkout (file://[LOCAL_GIT_REPO]#[GIT_HASH])
910
│ │ └── Instantiate backend (pixi-build-rattler-build)
10-
│ │ └── Conda solve #5
11+
│ │ └── Conda solve #6
1112
│ └── Source record (foobar-desktop @ git+file://[LOCAL_GIT_REPO]?subdirectory=recipe&rev=[GIT_REF]#[GIT_HASH])
1213
├── Source metadata (foobar @ git+file://[LOCAL_GIT_REPO]?subdirectory=recipe&rev=[GIT_REF]#[GIT_HASH])
1314
│ └── Source record (foobar @ git+file://[LOCAL_GIT_REPO]?subdirectory=recipe&rev=[GIT_REF]#[GIT_HASH])
14-
└── Conda solve #9
15+
└── Conda solve #10
1516
Pixi install (test-env)
1617
├── Backend source build (foobar-desktop)
1718
└── Backend source build (foobar)

crates/pixi_compute_sources/src/git.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,19 @@ impl LifecycleKind for GitReporterLifecycle {
9595
}
9696
}
9797

98-
/// Dedup key for a git checkout. Keyed on [`RepositoryReference`]
99-
/// (normalized URL + reference, no `precise`) so callers that differ
100-
/// only in whether they pre-resolved the commit still dedup.
98+
/// Dedup key for a git checkout. Keyed on the full [`GitUrl`]: URL,
99+
/// reference, AND `precise` commit, so a caller asking for a specific
100+
/// commit doesn't collide with one asking only for the branch.
101+
/// Stripping `precise` from the key let `checkout_pinned_source(A)`
102+
/// silently return the branch's HEAD instead of commit `A`
103+
/// (prefix-dev/pixi#6073).
101104
#[derive(Clone, Debug, Display, Hash, PartialEq, Eq)]
102-
#[display("{}@{}", _0.url.as_url(), _0.reference)]
103-
pub struct CheckoutGit(RepositoryReference);
105+
#[display("{}@{}", _0.repository(), _0.reference())]
106+
pub struct CheckoutGit(GitUrl);
104107

105108
impl CheckoutGit {
106109
pub fn new(git_url: &GitUrl) -> Self {
107-
Self(RepositoryReference::from(git_url))
110+
Self(git_url.clone())
108111
}
109112
}
110113

@@ -119,8 +122,9 @@ impl Key for CheckoutGit {
119122
let semaphore = data.git_checkout_semaphore().cloned();
120123
let reporter = data.git_checkout_reporter().cloned();
121124

125+
let reporter_env = RepositoryReference::from(&self.0);
122126
let lifecycle =
123-
ReporterLifecycle::<GitReporterLifecycle>::queued(reporter.as_deref(), &self.0);
127+
ReporterLifecycle::<GitReporterLifecycle>::queued(reporter.as_deref(), &reporter_env);
124128

125129
let _permit = match semaphore.as_ref() {
126130
Some(s) => Some(
@@ -132,14 +136,12 @@ impl Key for CheckoutGit {
132136
};
133137
let _lifecycle = lifecycle.start();
134138

135-
// `from_reference` auto-fills `precise` from a full-commit
136-
// reference, so the resolver skips ref-resolution when it can.
137-
let git_url =
138-
GitUrl::from_reference(self.0.url.clone().into_url(), self.0.reference.clone());
139-
139+
// Pass the original `GitUrl` straight through so the resolver
140+
// honours `precise` when set (pinned checkout) and advances to
141+
// the branch HEAD when not (fresh resolve).
140142
Arc::new(
141143
resolver
142-
.fetch(git_url, client, cache_dir.into_std_path_buf(), None)
144+
.fetch(self.0.clone(), client, cache_dir.into_std_path_buf(), None)
143145
.await,
144146
)
145147
}

0 commit comments

Comments
 (0)