Skip to content

Commit

Permalink
Auto merge of #6742 - hugwijst:yanked_local_registry_bug, r=alexcrichton
Browse files Browse the repository at this point in the history
Fix resolving yanked crates when using a local registry.

Fixes #6741.
  • Loading branch information
bors committed Mar 13, 2019
2 parents 0e35bd8 + 915b49d commit 8ebf915
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/cargo/core/source/source_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ impl SourceId {
Ok(p) => p,
Err(()) => panic!("path sources cannot be remote"),
};
Ok(Box::new(RegistrySource::local(self, &path, config)))
Ok(Box::new(RegistrySource::local(
self,
&path,
yanked_whitelist,
config,
)))
}
Kind::Directory => {
let path = match self.inner.url.to_file_path() {
Expand Down
9 changes: 7 additions & 2 deletions src/cargo/sources/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,20 @@ impl<'cfg> RegistrySource<'cfg> {
)
}

pub fn local(source_id: SourceId, path: &Path, config: &'cfg Config) -> RegistrySource<'cfg> {
pub fn local(
source_id: SourceId,
path: &Path,
yanked_whitelist: &HashSet<PackageId>,
config: &'cfg Config,
) -> RegistrySource<'cfg> {
let name = short_name(source_id);
let ops = local::LocalRegistry::new(path, config, &name);
RegistrySource::new(
source_id,
config,
&name,
Box::new(ops),
&HashSet::new(),
yanked_whitelist,
false,
)
}
Expand Down
41 changes: 40 additions & 1 deletion tests/testsuite/local_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs::{self, File};
use std::io::prelude::*;

use crate::support::paths::{self, CargoPathExt};
use crate::support::registry::Package;
use crate::support::registry::{registry_path, Package};
use crate::support::{basic_manifest, project};

fn setup() {
Expand Down Expand Up @@ -61,6 +61,45 @@ fn simple() {
p.cargo("test").run();
}

#[test]
fn depend_on_yanked() {
setup();
Package::new("bar", "0.0.1").local(true).publish();

let p = project()
.file(
"Cargo.toml",
r#"
[project]
name = "foo"
version = "0.0.1"
authors = []
[dependencies]
bar = "0.0.1"
"#,
)
.file("src/lib.rs", "")
.build();

// Run cargo to create lock file.
p.cargo("check").run();

registry_path().join("index").join("3").rm_rf();
Package::new("bar", "0.0.1")
.local(true)
.yanked(true)
.publish();

p.cargo("check")
.with_stderr(
"\
[FINISHED] [..]
",
)
.run();
}

#[test]
fn multiple_versions() {
setup();
Expand Down

0 comments on commit 8ebf915

Please sign in to comment.