Skip to content

Commit

Permalink
In check_not_dirty, WARN if no (git) VCS is recognized; fix tests.
Browse files Browse the repository at this point in the history
github cc: rust-lang#5786
  • Loading branch information
dekellum committed Jul 28, 2018
1 parent 773e3b6 commit adc5074
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn package(ws: &Workspace, opts: &PackageOpts) -> CargoResult<Option<FileLoc
}

if !opts.allow_dirty {
check_not_dirty(pkg, &src)?;
check_not_dirty(pkg, &src, &config)?;
}

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

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

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

fn git(p: &Package, src: &PathSource, repo: &git2::Repository) -> CargoResult<()> {
Expand Down
2 changes: 2 additions & 0 deletions tests/testsuite/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ fn exclude() {
"\
[WARNING] manifest has no description[..]
See http://doc.crates.io/manifest.html#package-metadata for more info.
[WARNING] No (git) VCS found
[PACKAGING] foo v0.0.1 ([..])
[WARNING] [..] file `dir_root_1[/]some_dir[/]file` WILL be excluded [..]
See [..]
Expand Down Expand Up @@ -488,6 +489,7 @@ fn include() {
"\
[WARNING] manifest has no description[..]
See http://doc.crates.io/manifest.html#package-metadata for more info.
[WARNING] No (git) VCS found
[PACKAGING] foo v0.0.1 ([..])
[ARCHIVING] [..]
[ARCHIVING] [..]
Expand Down

0 comments on commit adc5074

Please sign in to comment.