Skip to content

Commit cdbc76b

Browse files
committed
Auto merge of #2296 - alexcrichton:wow-thats-a-bad-bug, r=brson
There was a previous bug where if any crate's name was the start of the crate being updated that the crate wouldn't resolve at all, and this fixes the prefix checking error bug. cc #2293
2 parents d9e8c60 + f709175 commit cdbc76b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/cargo/sources/registry.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,8 @@ impl<'cfg> Registry for RegistrySource<'cfg> {
505505
// version requested (agument to `--precise`).
506506
summaries.retain(|s| {
507507
match self.source_id.precise() {
508-
Some(p) if p.starts_with(dep.name()) => {
508+
Some(p) if p.starts_with(dep.name()) &&
509+
p[dep.name().len()..].starts_with("=") => {
509510
let vers = &p[dep.name().len() + 1..];
510511
s.version().to_string() == vers
511512
}

tests/test_cargo_registry.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,3 +932,27 @@ test!(bundled_crate_in_registry {
932932

933933
assert_that(p.cargo("run"), execs().with_status(0));
934934
});
935+
936+
test!(update_same_prefix_oh_my_how_was_this_a_bug {
937+
let p = project("foo")
938+
.file("Cargo.toml", r#"
939+
[project]
940+
name = "ugh"
941+
version = "0.5.0"
942+
authors = []
943+
944+
[dependencies]
945+
foo = "0.1"
946+
"#)
947+
.file("src/main.rs", "fn main() {}");
948+
p.build();
949+
950+
Package::new("foobar", "0.2.0").publish();
951+
Package::new("foo", "0.1.0")
952+
.dep("foobar", "0.2.0")
953+
.publish();
954+
955+
assert_that(p.cargo("generate-lockfile"), execs().with_status(0));
956+
assert_that(p.cargo("update").arg("-pfoobar").arg("--precise=0.2.0"),
957+
execs().with_status(0));
958+
});

0 commit comments

Comments
 (0)