Skip to content

Commit

Permalink
Auto merge of #3217 - alexcrichton:fix-regression, r=brson
Browse files Browse the repository at this point in the history
Ignore summaries in downloaded crates

Unfortunately historical Cargo bugs have made it such that the index sometimes
differs from the actual crate we download. Let's respect the index, however,
which should be our source of truth.

Closes #3214
  • Loading branch information
bors authored Oct 20, 2016
2 parents 9a0801d + 41ff55e commit 51eec2c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ impl Encodable for Target {
}

impl Manifest {
pub fn new(summary: Summary, targets: Vec<Target>,
pub fn new(summary: Summary,
targets: Vec<Target>,
exclude: Vec<String>,
include: Vec<String>,
links: Option<String>,
Expand Down
14 changes: 13 additions & 1 deletion src/cargo/sources/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,19 @@ impl<'cfg> Source for RegistrySource<'cfg> {
}));
let mut src = PathSource::new(&path, &self.source_id, self.config);
try!(src.update());
src.download(package)
let pkg = try!(src.download(package));

// Unfortunately the index and the actual Cargo.toml in the index can
// differ due to historical Cargo bugs. To paper over these we trash the
// *summary* loaded from the Cargo.toml we just downloaded with the one
// we loaded from the index.
let summaries = try!(self.index.summaries(package.name()));
let summary = summaries.iter().map(|s| &s.0).find(|s| {
s.package_id() == package
}).expect("summary not found");
let mut manifest = pkg.manifest().clone();
manifest.set_summary(summary.clone());
Ok(Package::new(manifest, pkg.manifest_path()))
}

fn fingerprint(&self, pkg: &Package) -> CargoResult<String> {
Expand Down
34 changes: 34 additions & 0 deletions tests/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,3 +1340,37 @@ this warning.
[FINISHED] [..]
"));
}

#[test]
fn toml_lies_but_index_is_truth() {
Package::new("foo", "0.2.0").publish();
Package::new("bar", "0.3.0")
.dep("foo", "0.2.0")
.file("Cargo.toml", r#"
[project]
name = "bar"
version = "0.3.0"
authors = []
[dependencies]
foo = "0.1.0"
"#)
.file("src/lib.rs", "extern crate foo;")
.publish();

let p = project("foo")
.file("Cargo.toml", r#"
[project]
name = "bar"
version = "0.5.0"
authors = []
[dependencies]
bar = "0.3"
"#)
.file("src/main.rs", "fn main() {}");
p.build();

assert_that(p.cargo("build").arg("-v"),
execs().with_status(0));
}

0 comments on commit 51eec2c

Please sign in to comment.