Skip to content

Commit

Permalink
Auto merge of #6280 - zachreizner:master, r=dwijnand
Browse files Browse the repository at this point in the history
use allow-dirty option in `cargo package` to skip vcs checks

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 uses `--allow-dirty` to imply to `cargo package` that it should not be checking for version control information, fixing this issue.
  • Loading branch information
bors committed Nov 29, 2018
2 parents d8f066e + fd5fb6e commit e70bccf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ 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 = check_repo_state(pkg, &src_files, &config, opts.allow_dirty)?
.map(|h| json!({"git":{"sha1": h}}));
let vcs_info = if !opts.allow_dirty {
check_repo_state(pkg, &src_files, &config, opts.allow_dirty)?
.map(|h| json!({"git":{"sha1": h}}))
} else {
None
};

if opts.list {
let root = pkg.root();
Expand Down

0 comments on commit e70bccf

Please sign in to comment.