style fixes

This commit is contained in:
Joonas Koivunen 2017-04-14 10:55:26 +03:00
parent d31f24bdbb
commit e9908c71e2
2 changed files with 19 additions and 10 deletions

View file

@ -294,16 +294,17 @@ impl<'a> GitCheckout<'a> {
info!("update submodules for: {:?}", repo.workdir().unwrap());
for mut child in repo.submodules()?.into_iter() {
update_submodule(repo, &mut child, cargo_config).chain_error(||
human(
format!("Failed to update submodule `{}`",
child.name().unwrap_or("")))
)?;
update_submodule(repo, &mut child, cargo_config).chain_error(|| {
human(format!("Failed to update submodule `{}`",
child.name().unwrap_or("")))
})?;
}
Ok(())
}
fn update_submodule(parent: &git2::Repository, child: &mut git2::Submodule, cargo_config: &Config) -> CargoResult<()> {
fn update_submodule(parent: &git2::Repository,
child: &mut git2::Submodule,
cargo_config: &Config) -> CargoResult<()> {
child.init(false)?;
let url = child.url().chain_error(|| {
internal("non-utf8 url for submodule")

View file

@ -777,7 +777,13 @@ fn dep_with_bad_submodule() {
let repo = git2::Repository::open(&git_project2.root()).unwrap();
let original_submodule_ref = repo.refname_to_id("refs/heads/master").unwrap();
let commit = repo.find_commit(original_submodule_ref).unwrap();
commit.amend(Some("refs/heads/master"), None, None, None, Some("something something"), None).unwrap();
commit.amend(
Some("refs/heads/master"),
None,
None,
None,
Some("something something"),
None).unwrap();
let project = project
.file("Cargo.toml", &format!(r#"
@ -796,8 +802,7 @@ fn dep_with_bad_submodule() {
pub fn foo() { dep1::dep() }
");
assert_that(project.cargo_process("build"),
execs().with_stderr(format!("\
let expected = format!("\
[UPDATING] git repository [..]
[ERROR] failed to load source for a dependency on `dep1`
@ -807,7 +812,10 @@ Caused by:
Caused by:
Failed to update submodule `src`
To learn more, run the command again with --verbose.\n", path2url(git_project.root()))).with_status(101));
To learn more, run the command again with --verbose.\n", path2url(git_project.root()));
assert_that(project.cargo_process("build"),
execs().with_stderr(expected).with_status(101));
}
#[test]