Skip to content

Commit

Permalink
fix(vendor): trust crate version only when coming from registries
Browse files Browse the repository at this point in the history
  • Loading branch information
stormshield-guillaumed committed Sep 12, 2024
1 parent 5fa43ee commit a53b81a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/cargo/ops/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ fn sync(
let dst = canonical_destination.join(&dst_name);
to_remove.remove(&dst);
let cksum = dst.join(".cargo-checksum.json");
if dir_has_version_suffix && cksum.exists() {
// Always re-copy directory without version suffix in case the version changed
// Registries are the only immutable sources,
// path and git dependencies' versions cannot be trusted to mean "no change"
if dir_has_version_suffix && id.source_id().is_registry() && cksum.exists() {
// Don't re-copy directory with version suffix in case it comes from a registry
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ fn git_update_rev() {
.run();

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

#[cargo_test]
Expand Down

0 comments on commit a53b81a

Please sign in to comment.