Skip to content

Commit

Permalink
use allow-dirty option in cargo package to skip vcs checks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zachreizner committed Nov 28, 2018
1 parent 09cc2f2 commit fd5fb6e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 8 deletions.
5 changes: 0 additions & 5 deletions src/bin/cargo/commands/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>,
pub target: Option<String>,
pub registry: Option<String>,
Expand Down Expand Up @@ -56,7 +55,7 @@ pub fn package(ws: &Workspace, opts: &PackageOpts) -> CargoResult<Option<FileLoc
// Check (git) repository state, getting the current commit hash if not
// dirty. This will `bail!` if dirty, unless allow_dirty. Produce json
// info for any sha1 (HEAD revision) returned.
let vcs_info = if opts.use_vcs {
let vcs_info = if !opts.allow_dirty {
check_repo_state(pkg, &src_files, &config, opts.allow_dirty)?
.map(|h| json!({"git":{"sha1": h}}))
} else {
Expand Down
1 change: 0 additions & 1 deletion src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ pub fn publish(ws: &Workspace, opts: &PublishOpts) -> 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(),
Expand Down

0 comments on commit fd5fb6e

Please sign in to comment.