mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
vendor: support alt registries
This commit is contained in:
parent
fc29c9cae1
commit
723748fabf
@ -258,6 +258,12 @@ fn sync(
|
|||||||
registry: None,
|
registry: None,
|
||||||
replace_with: merged_source_name.to_string(),
|
replace_with: merged_source_name.to_string(),
|
||||||
}
|
}
|
||||||
|
} else if source_id.is_remote_registry() {
|
||||||
|
let registry = source_id.url().to_string();
|
||||||
|
VendorSource::Registry {
|
||||||
|
registry: Some(registry),
|
||||||
|
replace_with: merged_source_name.to_string(),
|
||||||
|
}
|
||||||
} else if source_id.is_git() {
|
} else if source_id.is_git() {
|
||||||
let mut branch = None;
|
let mut branch = None;
|
||||||
let mut tag = None;
|
let mut tag = None;
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
//! Tests for the `cargo vendor` command.
|
//! Tests for the `cargo vendor` command.
|
||||||
|
//!
|
||||||
|
//! Note that every test here uses `--respect-source-config` so that the
|
||||||
|
//! "fake" crates.io is used. Otherwise `vendor` would download the crates.io
|
||||||
|
//! index from the network.
|
||||||
|
|
||||||
use cargo_test_support::git;
|
use cargo_test_support::git;
|
||||||
use cargo_test_support::registry::Package;
|
use cargo_test_support::registry::Package;
|
||||||
@ -584,3 +588,46 @@ fn ignore_hidden() {
|
|||||||
.iter()
|
.iter()
|
||||||
.all(|status| status.status() == git2::Status::CURRENT));
|
.all(|status| status.status() == git2::Status::CURRENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn config_instructions_works() {
|
||||||
|
// Check that the config instructions work for all dependency kinds.
|
||||||
|
Package::new("dep", "0.1.0").publish();
|
||||||
|
Package::new("altdep", "0.1.0").alternative(true).publish();
|
||||||
|
let git_project = git::new("gitdep", |project| {
|
||||||
|
project
|
||||||
|
.file("Cargo.toml", &basic_lib_manifest("gitdep"))
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
});
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
&format!(
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "foo"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
dep = "0.1"
|
||||||
|
altdep = {{version="0.1", registry="alternative"}}
|
||||||
|
gitdep = {{git='{}'}}
|
||||||
|
"#,
|
||||||
|
git_project.url()
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
.build();
|
||||||
|
let output = p
|
||||||
|
.cargo("vendor --respect-source-config")
|
||||||
|
.exec_with_output()
|
||||||
|
.unwrap();
|
||||||
|
let output = String::from_utf8(output.stdout).unwrap();
|
||||||
|
p.change_file(".cargo/config", &output);
|
||||||
|
|
||||||
|
p.cargo("check -v")
|
||||||
|
.with_stderr_contains("[..]foo/vendor/dep/src/lib.rs[..]")
|
||||||
|
.with_stderr_contains("[..]foo/vendor/altdep/src/lib.rs[..]")
|
||||||
|
.with_stderr_contains("[..]foo/vendor/gitdep/src/lib.rs[..]")
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user