Skip to content

Commit a59d202

Browse files
committed
Auto merge of #10348 - epage:vendor, r=alexcrichton
fix(vendor): Use tables for sample config Fixes #10345
2 parents 74ec39f + fb9d11b commit a59d202

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/cargo/ops/vendor.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ pub fn vendor(ws: &Workspace<'_>, opts: &VendorOptions<'_>) -> CargoResult<()> {
4040
config,
4141
"To use vendored sources, add this to your .cargo/config.toml for this project:\n\n"
4242
);
43-
crate::drop_print!(config, "{}", &toml::to_string(&vendor_config).unwrap());
43+
crate::drop_print!(
44+
config,
45+
"{}",
46+
&toml::to_string_pretty(&vendor_config).unwrap()
47+
);
4448
}
4549
}
4650

tests/testsuite/vendor.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,38 @@ fn vendor_simple() {
3737
p.cargo("build").run();
3838
}
3939

40+
#[cargo_test]
41+
fn vendor_sample_config() {
42+
let p = project()
43+
.file(
44+
"Cargo.toml",
45+
r#"
46+
[package]
47+
name = "foo"
48+
version = "0.1.0"
49+
50+
[dependencies]
51+
log = "0.3.5"
52+
"#,
53+
)
54+
.file("src/lib.rs", "")
55+
.build();
56+
57+
Package::new("log", "0.3.5").publish();
58+
59+
p.cargo("vendor --respect-source-config")
60+
.with_stdout(
61+
r#"
62+
[source.crates-io]
63+
replace-with = "vendored-sources"
64+
65+
[source.vendored-sources]
66+
directory = "vendor"
67+
"#,
68+
)
69+
.run();
70+
}
71+
4072
fn add_vendor_config(p: &Project) {
4173
p.change_file(
4274
".cargo/config",

0 commit comments

Comments
 (0)