Commit 458474b6 authored by Ben Boeckel's avatar Ben Boeckel

rustfmt: reformat function call arguments

parent b68441b1
Pipeline #115491 passed with stage
......@@ -93,13 +93,15 @@ pub enum MergeStatus {
impl Display for MergeStatus {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f,
"{}",
match *self {
MergeStatus::NoCommonHistory => "no common history",
MergeStatus::AlreadyMerged => "already merged",
MergeStatus::Mergeable(_) => "mergeable",
})
write!(
f,
"{}",
match *self {
MergeStatus::NoCommonHistory => "no common history",
MergeStatus::AlreadyMerged => "already merged",
MergeStatus::Mergeable(_) => "mergeable",
},
)
}
}
......@@ -159,9 +161,11 @@ impl GitContext {
.output()
.chain_err(|| "failed to construct fetch command")?;
if !fetch.status.success() {
bail!(ErrorKind::Git(format!("fetch from {} failed: {}",
remote.as_ref(),
String::from_utf8_lossy(&fetch.stderr))));
bail!(ErrorKind::Git(format!(
"fetch from {} failed: {}",
remote.as_ref(),
String::from_utf8_lossy(&fetch.stderr)
)));
}
Ok(())
......@@ -174,8 +178,10 @@ impl GitContext {
N: AsRef<str>,
T: AsRef<str>,
{
self.fetch(remote,
&[&format!("{}:{}", refname.as_ref(), target.as_ref())])
self.fetch(
remote,
&[&format!("{}:{}", refname.as_ref(), target.as_ref())],
)
}
/// Fetch a commit from the given remote into a specific local refname, allowing rewinds.
......@@ -185,9 +191,11 @@ impl GitContext {
N: AsRef<str>,
T: AsRef<str>,
{
self.fetch_into(remote.as_ref(),
format!("+{}", refname.as_ref()),
target.as_ref())
self.fetch_into(
remote.as_ref(),
format!("+{}", refname.as_ref()),
target.as_ref(),
)
}
/// Create a tree where further work on the given revision can occur.
......@@ -219,9 +227,11 @@ impl GitContext {
.output()
.chain_err(|| "failed to construct for-each-ref command")?;
if !for_each_ref.status.success() {
bail!(ErrorKind::Git(format!("listing all {} refs: {}",
ref_prefix,
String::from_utf8_lossy(&for_each_ref.stderr))));
bail!(ErrorKind::Git(format!(
"listing all {} refs: {}",
ref_prefix,
String::from_utf8_lossy(&for_each_ref.stderr)
)));
}
let refs = String::from_utf8_lossy(&for_each_ref.stdout);
......
......@@ -128,8 +128,10 @@ impl<'a> MergeCommand<'a> {
.wait_with_output()
.chain_err(|| "failed to execute commit-tree command")?;
if !commit_tree.status.success() {
bail!(ErrorKind::Git(format!("failed to commit the merged tree: {}",
String::from_utf8_lossy(&commit_tree.stderr))));
bail!(ErrorKind::Git(format!(
"failed to commit the merged tree: {}",
String::from_utf8_lossy(&commit_tree.stderr)
)));
}
let merge_commit = String::from_utf8_lossy(&commit_tree.stdout);
......@@ -204,8 +206,10 @@ where
.output()
.chain_err(|| "failed to construct ls-files command")?;
if !ls_files.status.success() {
bail!(ErrorKind::Git(format!("listing paths in the index: {}",
String::from_utf8_lossy(&ls_files.stderr))));
bail!(ErrorKind::Git(format!(
"listing paths in the index: {}",
String::from_utf8_lossy(&ls_files.stderr)
)));
}
checkout_files(ctx, &ls_files.stdout)
......@@ -241,8 +245,10 @@ fn checkout_files(ctx: &WorkareaGitContext, files: &[u8]) -> Result<()> {
.expect("expected checkout-index to have a stderr")
.read_to_end(&mut stderr)
.chain_err(|| "failed to read from checkout-index")?;
bail!(ErrorKind::Git(format!("running checkout-index: {}",
String::from_utf8_lossy(&stderr))));
bail!(ErrorKind::Git(format!(
"running checkout-index: {}",
String::from_utf8_lossy(&stderr),
)));
}
// Update the index for the files we put into the context
......@@ -272,8 +278,10 @@ fn checkout_files(ctx: &WorkareaGitContext, files: &[u8]) -> Result<()> {
.expect("expected update-index to have a stderr")
.read_to_end(&mut stderr)
.chain_err(|| "failed to read from update-index")?;
bail!(ErrorKind::Git(format!("running update-index: {}",
String::from_utf8_lossy(&stderr))));
bail!(ErrorKind::Git(format!(
"running update-index: {}",
String::from_utf8_lossy(&stderr),
)));
}
Ok(())
......@@ -326,9 +334,11 @@ impl PreparingGitWorkArea {
.output()
.chain_err(|| "failed to construct read-tree command")?;
if !res.status.success() {
bail!(ErrorKind::Git(format!("reading the tree from {}: {}",
rev,
String::from_utf8_lossy(&res.stderr))));
bail!(ErrorKind::Git(format!(
"reading the tree from {}: {}",
rev,
String::from_utf8_lossy(&res.stderr)
)));
}
// Make the index believe the working tree is fine.
......@@ -372,8 +382,10 @@ impl PreparingGitWorkArea {
.output()
.chain_err(|| "failed to construct config command for submodules")?;
if !config.status.success() {
bail!(ErrorKind::Git(format!("reading the submodule configuration: {}",
String::from_utf8_lossy(&config.stderr))));
bail!(ErrorKind::Git(format!(
"reading the submodule configuration: {}",
String::from_utf8_lossy(&config.stderr)
)));
}
let config = String::from_utf8_lossy(&config.stdout);
......@@ -384,22 +396,26 @@ impl PreparingGitWorkArea {
.filter_map(|l| SUBMODULE_CONFIG_RE.captures(l));
for capture in captures {
submodule_config
.entry(capture
.name("name")
.expect("the submodule regex should have a 'name' group")
.as_str()
.to_string())
.entry(
capture
.name("name")
.expect("the submodule regex should have a 'name' group")
.as_str()
.to_string(),
)
.or_insert_with(HashMap::new)
.insert(capture
.name("key")
.expect("the submodule regex should have a 'key' group")
.as_str()
.to_string(),
capture
.name("value")
.expect("the submodule regex should have a 'value' group")
.as_str()
.to_string());
.insert(
capture
.name("key")
.expect("the submodule regex should have a 'key' group")
.as_str()
.to_string(),
capture
.name("value")
.expect("the submodule regex should have a 'value' group")
.as_str()
.to_string(),
);
}
let gitmoduledir = self.context.gitdir().join("modules");
......@@ -486,8 +502,10 @@ impl GitWorkArea {
};
let gitfiledir = self.work_tree().join(path);
fs::create_dir_all(&gitfiledir).chain_err(|| {
format!("failed to create the {} submodule directory for the workarea",
name)
format!(
"failed to create the {} submodule directory for the workarea",
name,
)
})?;
let mut gitfile = File::create(gitfiledir.join(".git"))
......@@ -529,9 +547,7 @@ impl GitWorkArea {
submod_path.as_str() == path.to_string_lossy()
})
})
.map(|(name, config)| {
(name, config.get("branch").map_or("master", String::as_str))
});
.map(|(name, config)| (name, config.get("branch").map_or("master", String::as_str)));
let (name, branch) = if let Some((name, branch_name)) = branch_info {
if branch_name == "." {
......@@ -610,8 +626,10 @@ impl GitWorkArea {
.output()
.chain_err(|| "failed to construct ls-files command for conflict resolution")?;
if !ls_files.status.success() {
bail!(ErrorKind::Git(format!("listing unmerged files: {}",
String::from_utf8_lossy(&ls_files.stderr))));
bail!(ErrorKind::Git(format!(
"listing unmerged files: {}",
String::from_utf8_lossy(&ls_files.stderr)
)));
}
let conflicts = String::from_utf8_lossy(&ls_files.stdout);
......@@ -623,9 +641,11 @@ impl GitWorkArea {
for conflict in conflicts.lines() {
let info = conflict.split_whitespace().collect::<Vec<_>>();
assert!(info.len() == 4,
"expected 4 entries for a conflict, received {}",
info.len());
assert!(
info.len() == 4,
"expected 4 entries for a conflict, received {}",
info.len(),
);
let permissions = info[0];
let hash = info[1];
......@@ -724,8 +744,10 @@ impl GitWorkArea {
.output()
.chain_err(|| "failed to construct write-tree command")?;
if !write_tree.status.success() {
bail!(ErrorKind::Git(format!("writing the tree object: {}",
String::from_utf8_lossy(&write_tree.stderr))));
bail!(ErrorKind::Git(format!(
"writing the tree object: {}",
String::from_utf8_lossy(&write_tree.stderr)
)));
}
let merged_tree = String::from_utf8_lossy(&write_tree.stdout);
let merged_tree = merged_tree.trim();
......
......@@ -62,8 +62,10 @@ fn git_context(workspace_path: &Path) -> GitContext {
.output()
.unwrap();
if !clone.status.success() {
panic!("origin clone failed: {}",
String::from_utf8_lossy(&clone.stderr));
panic!(
"origin clone failed: {}",
String::from_utf8_lossy(&clone.stderr),
);
}
GitContext::new(gitdir)
......@@ -78,8 +80,10 @@ fn git_context_submodule(workspace_path: &Path, commit: &CommitId) -> GitContext
.output()
.unwrap();
if !clone.status.success() {
panic!("origin clone failed: {}",
String::from_utf8_lossy(&clone.stderr));
panic!(
"origin clone failed: {}",
String::from_utf8_lossy(&clone.stderr),
);
}
let ctx = GitContext::new(gitdir.join(".git"));
......@@ -92,8 +96,10 @@ fn git_context_submodule(workspace_path: &Path, commit: &CommitId) -> GitContext
.output()
.unwrap();
if !checkout.status.success() {
panic!("checkout failed: {}",
String::from_utf8_lossy(&checkout.stderr));
panic!(
"checkout failed: {}",
String::from_utf8_lossy(&checkout.stderr),
);
}
let submodule_update = ctx
......@@ -105,8 +111,10 @@ fn git_context_submodule(workspace_path: &Path, commit: &CommitId) -> GitContext
.output()
.unwrap();
if !submodule_update.status.success() {
panic!("submodule update failed: {}",
String::from_utf8_lossy(&submodule_update.stderr));
panic!(
"submodule update failed: {}",
String::from_utf8_lossy(&submodule_update.stderr),
);
}
ctx
......@@ -276,10 +284,10 @@ fn test_mergeable() {
if let MergeStatus::Mergeable(bases) = status {
assert_eq!(bases, &[base]);
} else {
panic!("topic {} should be mergeable into {}: {:?}",
topic,
base,
status);
panic!(
"topic {} should be mergeable into {}: {:?}",
topic, base, status,
);
}
}
......@@ -296,10 +304,10 @@ fn test_mergeable_already_merged() {
if let MergeStatus::AlreadyMerged = status {
// OK
} else {
panic!("topic {} should already be merged into {}: {:?}",
topic,
base,
status);
panic!(
"topic {} should already be merged into {}: {:?}",
topic, base, status,
);
}
}
......@@ -316,10 +324,10 @@ fn test_mergeable_conflict() {
if let MergeStatus::Mergeable(bases) = status {
assert_eq!(bases, &[CommitId::new(BASE_COMMIT)]);
} else {
panic!("topic {} should be mergeable into {}: {:?}",
topic,
base,
status);
panic!(
"topic {} should be mergeable into {}: {:?}",
topic, base, status,
);
}
}
......@@ -341,10 +349,10 @@ fn test_mergeable_no_common_history() {
if let MergeStatus::NoCommonHistory = status {
// OK
} else {
panic!("topic {} should not have a common history with {}: {:?}",
topic,
base,
status);
panic!(
"topic {} should not have a common history with {}: {:?}",
topic, base, status,
);
}
}
......@@ -415,22 +423,26 @@ fn test_work_area_setup_submodule() {
.submodule_config()
.iter()
.map(|(name, config)| {
(name.as_str(),
config
.iter()
.map(|(key, value)| (key.as_str(), value.as_str()))
.sorted_by(|ref a, ref b| Ord::cmp(&a.0, &b.0)))
(
name.as_str(),
config
.iter()
.map(|(key, value)| (key.as_str(), value.as_str()))
.sorted_by(|ref a, ref b| Ord::cmp(&a.0, &b.0)),
)
})
.sorted_by(|ref a, ref b| Ord::cmp(&a.0, &b.0));
assert_eq!(submodule_config,
&[
("submodule",
vec![
("path", "submodule"),
("url", "https://gitlab.kitware.com/utils/test-repo.git"),
]),
]);
assert_eq!(
submodule_config,
&[(
"submodule",
vec![
("path", "submodule"),
("url", "https://gitlab.kitware.com/utils/test-repo.git"),
]
),],
);
}
#[test]
......@@ -447,22 +459,26 @@ fn test_work_area_setup_submodule_custom_name() {
.submodule_config()
.iter()
.map(|(name, config)| {
(name.as_str(),
config
.iter()
.map(|(key, value)| (key.as_str(), value.as_str()))
.sorted_by(|ref a, ref b| Ord::cmp(&a.0, &b.0)))
(
name.as_str(),
config
.iter()
.map(|(key, value)| (key.as_str(), value.as_str()))
.sorted_by(|ref a, ref b| Ord::cmp(&a.0, &b.0)),
)
})
.sorted_by(|ref a, ref b| Ord::cmp(&a.0, &b.0));
assert_eq!(submodule_config,
&[
("custom-name",
vec![
("path", "submodule"),
("url", "https://gitlab.kitware.com/utils/test-repo.git"),
]),
]);
assert_eq!(
submodule_config,
&[(
"custom-name",
vec![
("path", "submodule"),
("url", "https://gitlab.kitware.com/utils/test-repo.git"),
]
),],
);
}
#[test]
......@@ -493,18 +509,21 @@ fn test_setup_merge() {
.unwrap();
assert!(rev_parse.status.success());
let merged_tree = String::from_utf8_lossy(&rev_parse.stdout);
assert_eq!(merged_tree.trim(), "254e4e42cb914f935679319389e2af07eebb2157");
assert_eq!(
merged_tree.trim(),
"254e4e42cb914f935679319389e2af07eebb2157",
);
} else {
panic!("expected the merge from {} into {} to be fine: {:?}",
topic,
base,
merge);
panic!(
"expected the merge from {} into {} to be fine: {:?}",
topic, base, merge,
);
}
} else {
panic!("topic {} should be mergeable into {}: {:?}",
topic,
base,
status);
panic!(
"topic {} should be mergeable into {}: {:?}",
topic, base, status,
);
}
}
......@@ -533,12 +552,15 @@ fn test_setup_merge_ours() {
.unwrap();
assert!(rev_parse.status.success());
let merged_tree = String::from_utf8_lossy(&rev_parse.stdout);
assert_eq!(merged_tree.trim(), "d6e9a7ef309d55ab0bc68e978e34bea528d7bb94");
assert_eq!(
merged_tree.trim(),
"d6e9a7ef309d55ab0bc68e978e34bea528d7bb94",
);
} else {
panic!("expected the merge from {} into {} to be fine: {:?}",
topic,
base,
merge);
panic!(
"expected the merge from {} into {} to be fine: {:?}",
topic, base, merge,
);
}
}
......@@ -561,16 +583,16 @@ fn test_setup_merge_rewind() {
if let MergeResult::Ready(_) = merge {
// OK
} else {
panic!("expected the merge from {} into {} to be fine: {:?}",
topic,
base,
merge);
panic!(
"expected the merge from {} into {} to be fine: {:?}",
topic, base, merge,
);
}
} else {
panic!("topic {} should be mergeable into {}: {:?}",
topic,
base,
status);
panic!(
"topic {} should be mergeable into {}: {:?}",
topic, base, status,
);
}
}
......@@ -592,30 +614,33 @@ fn test_setup_merge_conflict() {
let merge = workarea.setup_merge(&bases, &base, &topic).unwrap();
if let MergeResult::Conflict(conflicts) = merge {
assert_eq!(conflicts.iter()
.map(|conflict| conflict.path().to_string_lossy())
.collect::<Vec<_>>(),
&["submodule".to_string()]);
assert_eq!(
conflicts
.iter()
.map(|conflict| conflict.path().to_string_lossy())
.collect::<Vec<_>>(),
&["submodule".to_string()],
);
if let Conflict::Path(_) = conflicts[0] {
// OK
} else {
panic!("expected the merge from {} into {} have a plain conflict: {:?}",
topic,
base,
conflicts[0]);
panic!(
"expected the merge from {} into {} have a plain conflict: {:?}",
topic, base, conflicts[0],
);
}
} else {
panic!("expected the merge from {} into {} to conflict: {:?}",
topic,
base,
merge);
panic!(
"expected the merge from {} into {} to conflict: {:?}",
topic, base, merge,
);
}
} else {
panic!("topic {} should be mergeable into {}: {:?}",
topic,
base,
status);
panic!(
"topic {} should be mergeable into {}: {:?}",
topic, base, status,
);
}
}
......@@ -636,31 +661,33 @@ fn test_setup_merge_submodule_conflict_resolution() {
let merge = workarea.setup_merge(&bases, &base, &topic).unwrap();
if let MergeResult::Conflict(conflicts) = merge {
assert_eq!(conflicts
.iter()
.map(|conflict| conflict.path().to_string_lossy())
.collect::<Vec<_>>(),
&["submodule".to_string()]);
assert_eq!(
conflicts
.iter()
.map(|conflict| conflict.path().to_string_lossy())
.collect::<Vec<_>>(),
&["submodule".to_string()],
);
if let Conflict::SubmoduleWithFix(_, ref fix) = conflicts[0] {
assert_eq!(fix, &CommitId::new(SUBMODULE_RESOLUTION));
} else {
panic!("expected the merge from {} into {} have a conflict resolution: {:?}",
topic,
base,
conflicts[0]);
panic!(
"expected the merge from {} into {} have a conflict resolution: {:?}",
topic, base, conflicts[0],
);
}
} else {
panic!("expected the merge from {} into {} to conflict: {:?}",
topic,
base,
merge);
panic!(
"expected the merge from {} into {} to conflict: {:?}",
topic, base, merge,
);
}
} else {
panic!("topic {} should be mergeable into {}: {:?}",
topic,
base,
status);
panic!(
"topic {} should be mergeable into {}: {:?}",
topic, base, status,
);
}
}
......@@ -685,16 +712,16 @@ fn test_setup_merge_submodule_not_merged() {
if let MergeResult::Ready(_) = merge {
// OK
} else {
panic!("expected the merge from {} into {} to be fine: {:?}",
topic,
base,
merge);
panic!(
"expected the merge from {} into {} to be fine: {:?}",
topic, base, merge,
);