Skip to content

Commit e70bccf

Browse files
committed
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.
2 parents d8f066e + fd5fb6e commit e70bccf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/cargo/ops/cargo_package.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ pub fn package(ws: &Workspace, opts: &PackageOpts) -> CargoResult<Option<FileLoc
5555
// Check (git) repository state, getting the current commit hash if not
5656
// dirty. This will `bail!` if dirty, unless allow_dirty. Produce json
5757
// info for any sha1 (HEAD revision) returned.
58-
let vcs_info = check_repo_state(pkg, &src_files, &config, opts.allow_dirty)?
59-
.map(|h| json!({"git":{"sha1": h}}));
58+
let vcs_info = if !opts.allow_dirty {
59+
check_repo_state(pkg, &src_files, &config, opts.allow_dirty)?
60+
.map(|h| json!({"git":{"sha1": h}}))
61+
} else {
62+
None
63+
};
6064

6165
if opts.list {
6266
let root = pkg.root();

0 commit comments

Comments
 (0)