Skip to content

Commit 8e3caf6

Browse files
committed
helper to check if precise is the same
1 parent 4720824 commit 8e3caf6

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

src/cargo/core/registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl<'cfg> PackageRegistry<'cfg> {
170170
// then we're done, otherwise we need to need to move forward
171171
// updating this source.
172172
Some((previous, _)) => {
173-
if previous.precise() == namespace.precise() {
173+
if previous.has_same_precise_as(namespace) {
174174
debug!("load/match {}", namespace);
175175
return Ok(());
176176
}

src/cargo/core/source_id.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ impl SourceId {
459459
self.inner.precise.as_deref() == Some("locked")
460460
}
461461

462+
/// Check if two sources have the same precise data field
463+
pub fn has_same_precise_as(self, other: Self) -> bool {
464+
self.inner.precise == other.inner.precise
465+
}
466+
462467
/// Check if the precise data field stores information for this `name`
463468
/// from a call to [SourceId::with_precise_registry_version].
464469
///

src/cargo/ops/cargo_generate_lockfile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
230230
b[i..]
231231
.iter()
232232
.take_while(|b| a == b)
233-
.all(|b| a.source_id().precise() != b.source_id().precise())
233+
.all(|b| !a.source_id().has_same_precise_as(b.source_id()))
234234
})
235235
.cloned()
236236
.collect()

src/cargo/ops/common_for_install_and_uninstall.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl InstallTracker {
215215
let precise_equal = if source_id.is_git() {
216216
// Git sources must have the exact same hash to be
217217
// considered "fresh".
218-
dupe_pkg_id.source_id().precise() == source_id.precise()
218+
dupe_pkg_id.source_id().has_same_precise_as(source_id)
219219
} else {
220220
true
221221
};

0 commit comments

Comments
 (0)