Skip to content

Commit a53b81a

Browse files
fix(vendor): trust crate version only when coming from registries
1 parent 5fa43ee commit a53b81a

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/cargo/ops/vendor.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,10 @@ fn sync(
207207
let dst = canonical_destination.join(&dst_name);
208208
to_remove.remove(&dst);
209209
let cksum = dst.join(".cargo-checksum.json");
210-
if dir_has_version_suffix && cksum.exists() {
211-
// Always re-copy directory without version suffix in case the version changed
210+
// Registries are the only immutable sources,
211+
// path and git dependencies' versions cannot be trusted to mean "no change"
212+
if dir_has_version_suffix && id.source_id().is_registry() && cksum.exists() {
213+
// Don't re-copy directory with version suffix in case it comes from a registry
212214
continue;
213215
}
214216

tests/testsuite/vendor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ fn git_update_rev() {
16261626
.run();
16271627

16281628
let lib = p.read_file("vendor/a-0.1.0/src/lib.rs");
1629-
assert_e2e().eq(lib, "");
1629+
assert_e2e().eq(lib, "pub fn f() {}");
16301630
}
16311631

16321632
#[cargo_test]

0 commit comments

Comments
 (0)