From d41f5ccd7ea91afee4f1a9d20b85dbcede135d3b Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Wed, 2 Mar 2022 08:41:44 -0600 Subject: [PATCH] vendor: Don't allow multiple values for --sync --- src/bin/cargo/commands/vendor.rs | 3 +- src/doc/man/cargo-vendor.md | 4 +- src/doc/man/generated_txt/cargo-vendor.txt | 5 +- src/doc/src/commands/cargo-vendor.md | 4 +- src/etc/man/cargo-vendor.1 | 4 +- tests/testsuite/vendor.rs | 66 ++++++++++++++++++++++ 6 files changed, 76 insertions(+), 10 deletions(-) diff --git a/src/bin/cargo/commands/vendor.rs b/src/bin/cargo/commands/vendor.rs index 697c235412c..88726697e22 100644 --- a/src/bin/cargo/commands/vendor.rs +++ b/src/bin/cargo/commands/vendor.rs @@ -24,8 +24,7 @@ pub fn cli() -> App { .help("Additional `Cargo.toml` to sync and vendor") .value_name("TOML") .allow_invalid_utf8(true) - .multiple_occurrences(true) - .multiple_values(true), + .multiple_occurrences(true), ) .arg( Arg::new("respect-source-config") diff --git a/src/doc/man/cargo-vendor.md b/src/doc/man/cargo-vendor.md index f7c4532035c..9fd977951e7 100644 --- a/src/doc/man/cargo-vendor.md +++ b/src/doc/man/cargo-vendor.md @@ -26,8 +26,8 @@ to use the vendored sources, which you will need to add to `.cargo/config.toml`. {{#options}} {{#option "`-s` _manifest_" "`--sync` _manifest_" }} -Specify extra `Cargo.toml` manifests to workspaces which should also be -vendored and synced to the output. +Specify an extra `Cargo.toml` manifest to workspaces which should also be +vendored and synced to the output. May be specified multiple times. {{/option}} {{#option "`--no-delete`" }} diff --git a/src/doc/man/generated_txt/cargo-vendor.txt b/src/doc/man/generated_txt/cargo-vendor.txt index 6004360bc0e..cfda5c3c808 100644 --- a/src/doc/man/generated_txt/cargo-vendor.txt +++ b/src/doc/man/generated_txt/cargo-vendor.txt @@ -20,8 +20,9 @@ DESCRIPTION OPTIONS Vendor Options -s manifest, --sync manifest - Specify extra Cargo.toml manifests to workspaces which should also - be vendored and synced to the output. + Specify an extra Cargo.toml manifest to workspaces which should also + be vendored and synced to the output. May be specified multiple + times. --no-delete Don't delete the "vendor" directory when vendoring, but rather keep diff --git a/src/doc/src/commands/cargo-vendor.md b/src/doc/src/commands/cargo-vendor.md index b1c6f858a37..ec689072477 100644 --- a/src/doc/src/commands/cargo-vendor.md +++ b/src/doc/src/commands/cargo-vendor.md @@ -27,8 +27,8 @@ to use the vendored sources, which you will need to add to `.cargo/config.toml`.
-s manifest
--sync manifest
-
Specify extra Cargo.toml manifests to workspaces which should also be -vendored and synced to the output.
+
Specify an extra Cargo.toml manifest to workspaces which should also be +vendored and synced to the output. May be specified multiple times.
--no-delete
diff --git a/src/etc/man/cargo-vendor.1 b/src/etc/man/cargo-vendor.1 index eeaf740467b..180d36a9b46 100644 --- a/src/etc/man/cargo-vendor.1 +++ b/src/etc/man/cargo-vendor.1 @@ -22,8 +22,8 @@ to use the vendored sources, which you will need to add to \fB\&.cargo/config.to \fB\-s\fR \fImanifest\fR, \fB\-\-sync\fR \fImanifest\fR .RS 4 -Specify extra \fBCargo.toml\fR manifests to workspaces which should also be -vendored and synced to the output. +Specify an extra \fBCargo.toml\fR manifest to workspaces which should also be +vendored and synced to the output. May be specified multiple times. .RE .sp \fB\-\-no\-delete\fR diff --git a/tests/testsuite/vendor.rs b/tests/testsuite/vendor.rs index 947ff324fa8..06feb5056b1 100644 --- a/tests/testsuite/vendor.rs +++ b/tests/testsuite/vendor.rs @@ -309,6 +309,72 @@ fn two_lockfiles() { p.cargo("build").cwd("bar").run(); } +#[cargo_test] +fn test_sync_argument() { + let p = project() + .no_manifest() + .file( + "foo/Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + bitflags = "=0.7.0" + "#, + ) + .file("foo/src/lib.rs", "") + .file( + "bar/Cargo.toml", + r#" + [package] + name = "bar" + version = "0.1.0" + + [dependencies] + bitflags = "=0.8.0" + "#, + ) + .file("bar/src/lib.rs", "") + .file( + "baz/Cargo.toml", + r#" + [package] + name = "baz" + version = "0.1.0" + + [dependencies] + bitflags = "=0.8.0" + "#, + ) + .file("baz/src/lib.rs", "") + .build(); + + Package::new("bitflags", "0.7.0").publish(); + Package::new("bitflags", "0.8.0").publish(); + + p.cargo("vendor --respect-source-config --manifest-path foo/Cargo.toml -s bar/Cargo.toml baz/Cargo.toml test_vendor") + .with_stderr("\ +error: Found argument 'test_vendor' which wasn't expected, or isn't valid in this context + +USAGE: + cargo[EXE] vendor [OPTIONS] [path] + +For more information try --help", + ) + .with_status(1) + .run(); + + p.cargo("vendor --respect-source-config --manifest-path foo/Cargo.toml -s bar/Cargo.toml -s baz/Cargo.toml test_vendor") + .run(); + + let lock = p.read_file("test_vendor/bitflags/Cargo.toml"); + assert!(lock.contains("version = \"0.8.0\"")); + let lock = p.read_file("test_vendor/bitflags-0.7.0/Cargo.toml"); + assert!(lock.contains("version = \"0.7.0\"")); +} + #[cargo_test] fn delete_old_crates() { let p = project()