Skip to content

Commit fd5fb6e

Browse files
committed
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.
1 parent 09cc2f2 commit fd5fb6e

File tree

3 files changed

+1
-8
lines changed

3 files changed

+1
-8
lines changed

src/bin/cargo/commands/package.rs

-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ pub fn cli() -> App {
2323
"allow-dirty",
2424
"Allow dirty working directories to be packaged",
2525
))
26-
.arg(opt(
27-
"no-vcs",
28-
"Ignore version control for packaging",
29-
))
3026
.arg_target_triple("Build for the target triple")
3127
.arg_target_dir()
3228
.arg_manifest_path()
@@ -43,7 +39,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
4339
list: args.is_present("list"),
4440
check_metadata: !args.is_present("no-metadata"),
4541
allow_dirty: args.is_present("allow-dirty"),
46-
use_vcs: !args.is_present("no-vcs"),
4742
target: args.target(),
4843
jobs: args.jobs()?,
4944
registry: None,

src/cargo/ops/cargo_package.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub struct PackageOpts<'cfg> {
2424
pub check_metadata: bool,
2525
pub allow_dirty: bool,
2626
pub verify: bool,
27-
pub use_vcs: bool,
2827
pub jobs: Option<u32>,
2928
pub target: Option<String>,
3029
pub registry: Option<String>,
@@ -56,7 +55,7 @@ pub fn package(ws: &Workspace, opts: &PackageOpts) -> CargoResult<Option<FileLoc
5655
// Check (git) repository state, getting the current commit hash if not
5756
// dirty. This will `bail!` if dirty, unless allow_dirty. Produce json
5857
// info for any sha1 (HEAD revision) returned.
59-
let vcs_info = if opts.use_vcs {
58+
let vcs_info = if !opts.allow_dirty {
6059
check_repo_state(pkg, &src_files, &config, opts.allow_dirty)?
6160
.map(|h| json!({"git":{"sha1": h}}))
6261
} else {

src/cargo/ops/registry.rs

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {
8080
list: false,
8181
check_metadata: true,
8282
allow_dirty: opts.allow_dirty,
83-
use_vcs: true,
8483
target: opts.target.clone(),
8584
jobs: opts.jobs,
8685
registry: opts.registry.clone(),

0 commit comments

Comments
 (0)