Skip to content

Commit adc5074

Browse files
committed
In check_not_dirty, WARN if no (git) VCS is recognized; fix tests.
github cc: #5786
1 parent 773e3b6 commit adc5074

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/cargo/ops/cargo_package.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub fn package(ws: &Workspace, opts: &PackageOpts) -> CargoResult<Option<FileLoc
5959
}
6060

6161
if !opts.allow_dirty {
62-
check_not_dirty(pkg, &src)?;
62+
check_not_dirty(pkg, &src, &config)?;
6363
}
6464

6565
let filename = format!("{}-{}.crate", pkg.name(), pkg.version());
@@ -152,7 +152,7 @@ fn verify_dependencies(pkg: &Package) -> CargoResult<()> {
152152
Ok(())
153153
}
154154

155-
fn check_not_dirty(p: &Package, src: &PathSource) -> CargoResult<()> {
155+
fn check_not_dirty(p: &Package, src: &PathSource, config: &Config) -> CargoResult<()> {
156156
if let Ok(repo) = git2::Repository::discover(p.root()) {
157157
if let Some(workdir) = repo.workdir() {
158158
debug!(
@@ -172,6 +172,7 @@ fn check_not_dirty(p: &Package, src: &PathSource) -> CargoResult<()> {
172172

173173
// No VCS recognized, we don't know if the directory is dirty or not, so we
174174
// have to assume that it's clean.
175+
config.shell().verbose(|shell| shell.warn("No (git) VCS found"))?;
175176
return Ok(());
176177

177178
fn git(p: &Package, src: &PathSource, repo: &git2::Repository) -> CargoResult<()> {

tests/testsuite/package.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ fn exclude() {
397397
"\
398398
[WARNING] manifest has no description[..]
399399
See http://doc.crates.io/manifest.html#package-metadata for more info.
400+
[WARNING] No (git) VCS found
400401
[PACKAGING] foo v0.0.1 ([..])
401402
[WARNING] [..] file `dir_root_1[/]some_dir[/]file` WILL be excluded [..]
402403
See [..]
@@ -488,6 +489,7 @@ fn include() {
488489
"\
489490
[WARNING] manifest has no description[..]
490491
See http://doc.crates.io/manifest.html#package-metadata for more info.
492+
[WARNING] No (git) VCS found
491493
[PACKAGING] foo v0.0.1 ([..])
492494
[ARCHIVING] [..]
493495
[ARCHIVING] [..]

0 commit comments

Comments
 (0)