From 09cc2f2cb636f4c37cb4850d5acbd0b19b65ff85 Mon Sep 17 00:00:00 2001 From: Zach Reizner Date: Wed, 7 Nov 2018 13:01:15 -0800 Subject: [PATCH 1/2] add --no-vcs option to `cargo package` If `cargo package` is run for a crate that is not version controlled in a way that cargo expects, git2 will overreach upwards and grab a irrelevant .git repo. This change adds `--no-vcs` as an option to `cargo package` to prevent this. --- src/bin/cargo/commands/package.rs | 5 +++++ src/cargo/ops/cargo_package.rs | 9 +++++++-- src/cargo/ops/registry.rs | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/bin/cargo/commands/package.rs b/src/bin/cargo/commands/package.rs index f5e9d918462..1da90841c15 100644 --- a/src/bin/cargo/commands/package.rs +++ b/src/bin/cargo/commands/package.rs @@ -23,6 +23,10 @@ pub fn cli() -> App { "allow-dirty", "Allow dirty working directories to be packaged", )) + .arg(opt( + "no-vcs", + "Ignore version control for packaging", + )) .arg_target_triple("Build for the target triple") .arg_target_dir() .arg_manifest_path() @@ -39,6 +43,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { list: args.is_present("list"), check_metadata: !args.is_present("no-metadata"), allow_dirty: args.is_present("allow-dirty"), + use_vcs: !args.is_present("no-vcs"), target: args.target(), jobs: args.jobs()?, registry: None, diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 37c82238ad5..f6da49935a7 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -24,6 +24,7 @@ pub struct PackageOpts<'cfg> { pub check_metadata: bool, pub allow_dirty: bool, pub verify: bool, + pub use_vcs: bool, pub jobs: Option, pub target: Option, pub registry: Option, @@ -55,8 +56,12 @@ pub fn package(ws: &Workspace, opts: &PackageOpts) -> CargoResult CargoResult<()> { list: false, check_metadata: true, allow_dirty: opts.allow_dirty, + use_vcs: true, target: opts.target.clone(), jobs: opts.jobs, registry: opts.registry.clone(), From fd5fb6e2dc4c6b06402d4c14df270edf6cd56b57 Mon Sep 17 00:00:00 2001 From: Zach Reizner Date: Tue, 27 Nov 2018 17:09:46 -0800 Subject: [PATCH 2/2] use allow-dirty option in `cargo package` to skip vcs checks To avoid introducing another flag, this change uses the `--allow-dirty` flag to skip checking for vcs information. This is logical because a user that passes that flag is indicating to `cargo package` that they do not care about the state of vcs at that time. --- src/bin/cargo/commands/package.rs | 5 ----- src/cargo/ops/cargo_package.rs | 3 +-- src/cargo/ops/registry.rs | 1 - 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/bin/cargo/commands/package.rs b/src/bin/cargo/commands/package.rs index 1da90841c15..f5e9d918462 100644 --- a/src/bin/cargo/commands/package.rs +++ b/src/bin/cargo/commands/package.rs @@ -23,10 +23,6 @@ pub fn cli() -> App { "allow-dirty", "Allow dirty working directories to be packaged", )) - .arg(opt( - "no-vcs", - "Ignore version control for packaging", - )) .arg_target_triple("Build for the target triple") .arg_target_dir() .arg_manifest_path() @@ -43,7 +39,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { list: args.is_present("list"), check_metadata: !args.is_present("no-metadata"), allow_dirty: args.is_present("allow-dirty"), - use_vcs: !args.is_present("no-vcs"), target: args.target(), jobs: args.jobs()?, registry: None, diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index f6da49935a7..e33961c1498 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -24,7 +24,6 @@ pub struct PackageOpts<'cfg> { pub check_metadata: bool, pub allow_dirty: bool, pub verify: bool, - pub use_vcs: bool, pub jobs: Option, pub target: Option, pub registry: Option, @@ -56,7 +55,7 @@ pub fn package(ws: &Workspace, opts: &PackageOpts) -> CargoResult CargoResult<()> { list: false, check_metadata: true, allow_dirty: opts.allow_dirty, - use_vcs: true, target: opts.target.clone(), jobs: opts.jobs, registry: opts.registry.clone(),