From 972763a8ee8bb56e47c296a8fb51f8ad3f0c9107 Mon Sep 17 00:00:00 2001 From: David Kellum Date: Sat, 28 Jul 2018 07:20:33 -0700 Subject: [PATCH 1/2] Improve verbose console and logging for finding git repo in package check --- src/cargo/ops/cargo_package.rs | 28 +++++++++++++++++++--------- tests/testsuite/package.rs | 2 ++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index c9850bfc223..822b519d7ca 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -59,7 +59,7 @@ pub fn package(ws: &Workspace, opts: &PackageOpts) -> CargoResult 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!( - "found a git repo at {:?}, checking if index present", - workdir - ); + debug!("found a git repo at {:?}", workdir); let path = p.manifest_path(); let path = path.strip_prefix(workdir).unwrap_or(path); if let Ok(status) = repo.status_file(path) { if (status & git2::Status::IGNORED).is_empty() { - debug!("Cargo.toml found in repo, checking if dirty"); + debug!( + "found (git) Cargo.toml at {:?} in workdir {:?}", + path, workdir + ); return git(p, src, &repo); } } + config.shell().verbose(|shell| { + shell.warn(format!( + "No (git) Cargo.toml found at `{}` in workdir `{}`", + path.display(), workdir.display() + )) + })?; } + } else { + config.shell().verbose(|shell| { + shell.warn(format!("No (git) VCS found for `{}`", p.root().display())) + })?; } - // No VCS recognized, we don't know if the directory is dirty or not, so we - // have to assume that it's clean. + // No VCS with a checked in Cargo.toml found. so we don't know if the + // directory is dirty or not, so we have to assume that it's clean. return Ok(()); fn git(p: &Package, src: &PathSource, repo: &git2::Repository) -> CargoResult<()> { diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index e00f6517888..49edb936c7b 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -326,6 +326,7 @@ fn exclude() { "\ [WARNING] manifest has no description[..] See http://doc.crates.io/manifest.html#package-metadata for more info. +[WARNING] No (git) Cargo.toml found at `[..]` in workdir `[..]` [PACKAGING] foo v0.0.1 ([..]) [WARNING] [..] file `dir_root_1[/]some_dir[/]file` WILL be excluded [..] See [..] @@ -415,6 +416,7 @@ fn include() { "\ [WARNING] manifest has no description[..] See http://doc.crates.io/manifest.html#package-metadata for more info. +[WARNING] No (git) Cargo.toml found at `[..]` in workdir `[..]` [PACKAGING] foo v0.0.1 ([..]) [ARCHIVING] [..] [ARCHIVING] [..] From fcd86f32703bebdca13f9dc6f9ae518b5a3c259b Mon Sep 17 00:00:00 2001 From: David Kellum Date: Thu, 2 Aug 2018 15:46:19 -0700 Subject: [PATCH 2/2] Update git2 minimal version to 0.7.5 for a fix --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index db75cebdd8b..95c2222b772 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ failure = "0.1.2" filetime = "0.2" flate2 = "1.0" fs2 = "0.4" -git2 = "0.7.3" +git2 = "0.7.5" git2-curl = "0.8.1" glob = "0.2.11" hex = "0.3"