Skip to content
This repository was archived by the owner on Jun 21, 2019. It is now read-only.

Commit

Permalink
Don't respect [source] .cargo/config configuration
Browse files Browse the repository at this point in the history
That just messes with us actually updating sources. Instead we want to go
straight to crates.io all the time to vendor new crates.

Closes #23
  • Loading branch information
alexcrichton committed May 14, 2017
1 parent db42ac7 commit 03e252f
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 40 deletions.
77 changes: 39 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ filesystem.
"""

[dependencies]
cargo = "0.18"
cargo = { git = 'https://github.com/rust-lang/cargo' }
rustc-serialize = "0.3"
env_logger = "0.4"
15 changes: 14 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,20 @@ struct Options {

fn main() {
env_logger::init().unwrap();
let config = Config::default().unwrap();

// We're doing the vendoring operation outselves, so we don't actually want
// to respect any of the `source` configuration in Cargo itself. That's
// intended for other consumers of Cargo, but we want to go straight to the
// source, e.g. crates.io, to fetch crates.
let config = {
let config_orig = Config::default().unwrap();
let mut values = config_orig.values().unwrap().clone();
values.remove("source");
let config = Config::default().unwrap();
config.set_values(values).unwrap();
config
};

let args = env::args().collect::<Vec<_>>();
let result = cargo::call_main_without_stdin(real_main, &config, r#"
Vendor all dependencies for a project locally
Expand Down
32 changes: 32 additions & 0 deletions tests/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,35 @@ fn two_lockfiles() {
run(Command::new("cargo").arg("build").current_dir(&dir.join("foo")));
run(Command::new("cargo").arg("build").current_dir(&dir.join("bar")));
}

#[test]
fn revendor_with_config() {
let dir = dir();

file(&dir, "Cargo.toml", r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
bitflags = "=0.7.0"
"#);
file(&dir, "src/lib.rs", "");

run(&mut vendor(&dir));
let lock = read(&dir.join("vendor/bitflags/Cargo.toml"));
assert!(lock.contains("version = \"0.7.0\""));

add_vendor_config(&dir);
file(&dir, "Cargo.toml", r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
bitflags = "=0.8.0"
"#);
run(&mut vendor(&dir));
let lock = read(&dir.join("vendor/bitflags/Cargo.toml"));
assert!(lock.contains("version = \"0.8.0\""));
}

0 comments on commit 03e252f

Please sign in to comment.