From d31f24bdbbfaee3595427063282c4c06d7edd53e Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Fri, 14 Apr 2017 08:38:55 +0300 Subject: [PATCH] git: adjust error on submodule update failure Now instead of reporting single generic "submodule update failed" a dependency specific submodule update failed error message will be reported and shown without --verbose. --- src/cargo/sources/git/utils.rs | 8 +++----- tests/git.rs | 9 +++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index fdf729b5b..26fbc917e 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -156,9 +156,7 @@ impl GitDatabase { } Err(..) => GitCheckout::clone_into(dest, self, rev)?, }; - checkout.update_submodules(cargo_config).chain_error(|| { - internal("failed to update submodules") - })?; + checkout.update_submodules(cargo_config)?; Ok(checkout) } @@ -297,8 +295,8 @@ impl<'a> GitCheckout<'a> { for mut child in repo.submodules()?.into_iter() { update_submodule(repo, &mut child, cargo_config).chain_error(|| - internal( - format!("failed to update submodule `{}`", + human( + format!("Failed to update submodule `{}`", child.name().unwrap_or(""))) )?; } diff --git a/tests/git.rs b/tests/git.rs index 71feb3146..43066847a 100644 --- a/tests/git.rs +++ b/tests/git.rs @@ -796,17 +796,18 @@ fn dep_with_bad_submodule() { pub fn foo() { dep1::dep() } "); - assert_that(project.cargo_process("build").arg("--verbose"), + assert_that(project.cargo_process("build"), execs().with_stderr(format!("\ [UPDATING] git repository [..] [ERROR] failed to load source for a dependency on `dep1` Caused by: - Failed to update submodules of [..] + Unable to update {} Caused by: - [9/-3] object not found - no match for id ({}) -", original_submodule_ref)).with_status(101)); + Failed to update submodule `src` + +To learn more, run the command again with --verbose.\n", path2url(git_project.root()))).with_status(101)); } #[test]