Skip to content

Commit a78097e

Browse files
committed
Fix formatting
1 parent 56efab9 commit a78097e

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

src/cmd/vendor.rs

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use crate::error::*;
1515
use crate::git::Git;
1616
use crate::sess::{DependencySource, Session};
1717
use glob::Pattern;
18+
use std::collections::HashSet;
1819
use std::path::Path;
1920
use std::path::PathBuf;
20-
use std::collections::HashSet;
2121
use tempfile::TempDir;
2222

2323
/// A patch linkage
@@ -152,17 +152,17 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
152152
// 1. file links over directory links eg 'a/file -> c/file' before 'b/ -> c/'
153153
// 2. subdirs (deeper paths) first eg 'a/aa/ -> c/aa' before 'a/ab -> c/'
154154
let mut sorted_links: Vec<_> = patch_links.clone();
155-
sorted_links.sort_by(|a,b| {
155+
sorted_links.sort_by(|a, b| {
156156
let a_is_file = a.to_prefix.is_file();
157157
let b_is_file = b.to_prefix.is_file();
158158

159159
if a_is_file != b_is_file {
160160
return b_is_file.cmp(&a_is_file);
161161
}
162-
162+
163163
let a_depth = a.to_prefix.iter().count();
164164
let b_depth = b.to_prefix.iter().count();
165-
165+
166166
b_depth.cmp(&a_depth)
167167
});
168168

@@ -175,17 +175,20 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
175175
.filter(|path| path.starts_with(&patch_link.to_prefix)) // subdir?
176176
.cloned()
177177
.collect();
178-
179-
seen_paths.insert(patch_link.to_prefix.clone());
178+
179+
seen_paths.insert(patch_link.to_prefix.clone());
180180
}
181181
let git = Git::new(tmp_path, &sess.config.git);
182182

183183
match matches.subcommand() {
184184
Some(("diff", matches)) => {
185185
// Apply patches
186-
sorted_links.clone().into_iter().try_for_each(|patch_link| {
187-
apply_patches(&rt, git, vendor_package.name.clone(), patch_link).map(|_| ())
188-
})?;
186+
sorted_links
187+
.clone()
188+
.into_iter()
189+
.try_for_each(|patch_link| {
190+
apply_patches(&rt, git, vendor_package.name.clone(), patch_link).map(|_| ())
191+
})?;
189192

190193
// Stage applied patches to clean working tree
191194
rt.block_on(git.add_all())?;
@@ -399,12 +402,13 @@ pub fn apply_patches(
399402
})
400403
.and_then(|_| {
401404
git.spawn_with(|c| {
402-
let is_file = patch_link.from_prefix
405+
let is_file = patch_link
406+
.from_prefix
403407
.clone()
404408
.prefix_paths(git.path)
405409
.unwrap()
406410
.is_file();
407-
411+
408412
let current_patch_target = if is_file {
409413
patch_link.from_prefix.parent().unwrap().to_str().unwrap()
410414
} else {
@@ -572,7 +576,6 @@ pub fn gen_format_patch(
572576
target_dir: impl AsRef<Path>,
573577
message: Option<&String>,
574578
) -> Result<()> {
575-
576579
// Local git
577580
let to_path = patch_link
578581
.to_prefix
@@ -606,21 +609,28 @@ pub fn gen_format_patch(
606609
// If the patch link maps a file, we operate in the file's parent directory
607610
// Therefore, only get the diff for that file.
608611
let include_pathspec = if !to_path.is_dir() {
609-
patch_link.to_prefix.file_name().unwrap().to_str().unwrap().to_string()
612+
patch_link
613+
.to_prefix
614+
.file_name()
615+
.unwrap()
616+
.to_str()
617+
.unwrap()
618+
.to_string()
610619
} else {
611620
".".to_string()
612621
};
613-
622+
614623
// Build the exclude pathspec to diff only the applicable files
615-
let exclude_pathspecs: Vec<String> = patch_link.exclude.iter().map(|path| {
616-
format!(":!{}", path.to_str().unwrap())
617-
})
618-
.collect();
619-
624+
let exclude_pathspecs: Vec<String> = patch_link
625+
.exclude
626+
.iter()
627+
.map(|path| format!(":!{}", path.to_str().unwrap()))
628+
.collect();
629+
620630
let mut diff_args = vec![
621631
"diff".to_string(),
622632
"--relative".to_string(),
623-
"--cached".to_string()
633+
"--cached".to_string(),
624634
];
625635

626636
diff_args.push(include_pathspec);
@@ -630,13 +640,7 @@ pub fn gen_format_patch(
630640

631641
// Get staged changes in dependency
632642
let get_diff_cached = rt
633-
.block_on(async {
634-
git_parent
635-
.spawn_with(|c| {
636-
c.args(&diff_args)
637-
})
638-
.await
639-
})
643+
.block_on(async { git_parent.spawn_with(|c| c.args(&diff_args)).await })
640644
.map_err(|cause| Error::chain("Failed to generate diff", cause))?;
641645

642646
if !get_diff_cached.is_empty() {

0 commit comments

Comments
 (0)