mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
Support alt-registry names in [patch] table.
This commit is contained in:
parent
bd5b21e997
commit
7eaa1cf70a
@ -1205,7 +1205,13 @@ impl TomlManifest {
|
||||
for (url, deps) in self.patch.iter().flat_map(|x| x) {
|
||||
let url = match &url[..] {
|
||||
CRATES_IO_REGISTRY => CRATES_IO_INDEX.parse().unwrap(),
|
||||
_ => url.to_url()?,
|
||||
_ => cx
|
||||
.config
|
||||
.get_registry_index(url)
|
||||
.or_else(|_| url.to_url())
|
||||
.chain_err(|| {
|
||||
format!("[patch] entry `{}` should be a URL or registry name", url)
|
||||
})?,
|
||||
};
|
||||
patch.insert(
|
||||
url,
|
||||
|
@ -514,3 +514,47 @@ fn passwords_in_url_forbidden() {
|
||||
.with_stderr_contains("error: Registry URLs may not contain passwords")
|
||||
.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn patch_alt_reg() {
|
||||
Package::new("bar", "0.1.0").publish();
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
cargo-features = ["alternative-registries"]
|
||||
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.0.1"
|
||||
|
||||
[dependencies]
|
||||
bar = { version = "0.1.0", registry = "alternative" }
|
||||
|
||||
[patch.alternative]
|
||||
bar = { path = "bar" }
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
"
|
||||
extern crate bar;
|
||||
pub fn f() { bar::bar(); }
|
||||
",
|
||||
)
|
||||
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
|
||||
.file("bar/src/lib.rs", "pub fn bar() {}")
|
||||
.build();
|
||||
|
||||
p.cargo("build")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] `[ROOT][..]` index
|
||||
[COMPILING] bar v0.1.0 ([CWD]/bar)
|
||||
[COMPILING] foo v0.0.1 ([CWD])
|
||||
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
@ -734,6 +734,9 @@ fn non_crates_io() {
|
||||
"\
|
||||
error: failed to parse manifest at `[..]`
|
||||
|
||||
Caused by:
|
||||
[patch] entry `some-other-source` should be a URL or registry name
|
||||
|
||||
Caused by:
|
||||
invalid url `some-other-source`: relative URL without a base
|
||||
",
|
||||
|
Loading…
x
Reference in New Issue
Block a user