Auto merge of #6280 - zachreizner:master, r=dwijnand

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.
This commit is contained in:
bors 2018-11-29 09:07:16 +00:00
commit e70bccff8b

View file

@ -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();