From 581938e214c9c9fbe5d440644a7f86b85771c49e Mon Sep 17 00:00:00 2001 From: rpschoenburg Date: Tue, 7 Jan 2025 15:43:39 -0800 Subject: [PATCH] Applying Linters --- src/lib/src/core/v0_19_0/add.rs | 17 +++++++++-------- src/lib/src/util/fs.rs | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/lib/src/core/v0_19_0/add.rs b/src/lib/src/core/v0_19_0/add.rs index 20fbd19ad..a15193554 100644 --- a/src/lib/src/core/v0_19_0/add.rs +++ b/src/lib/src/core/v0_19_0/add.rs @@ -219,7 +219,7 @@ pub fn process_add_dir( let added_file_counter_clone = Arc::clone(&added_file_counter); let unchanged_file_counter_clone = Arc::clone(&unchanged_file_counter); - let dir_path = util::fs::path_relative_to_dir(dir, &repo_path).unwrap(); + let dir_path = util::fs::path_relative_to_dir(dir, repo_path).unwrap(); let dir_node = maybe_load_directory(&repo, &maybe_head_commit, &dir_path).unwrap(); let seen_dirs = Arc::new(Mutex::new(HashSet::new())); @@ -246,7 +246,7 @@ pub fn process_add_dir( let seen_dirs_clone = Arc::clone(&seen_dirs); match process_add_file( &repo, - &repo_path, + repo_path, versions_path, staged_db, &dir_node, @@ -320,7 +320,7 @@ fn add_file_inner( .join(FILES_DIR); let mut maybe_dir_node = None; if let Some(head_commit) = maybe_head_commit { - let path = util::fs::path_relative_to_dir(path, &repo_path)?; + let path = util::fs::path_relative_to_dir(path, repo_path)?; let parent_path = path.parent().unwrap_or(Path::new("")); maybe_dir_node = CommitMerkleTree::dir_with_children(repo, head_commit, parent_path)?; } @@ -328,7 +328,7 @@ fn add_file_inner( let seen_dirs = Arc::new(Mutex::new(HashSet::new())); process_add_file( repo, - &repo_path, + repo_path, &versions_path, staged_db, &maybe_dir_node, @@ -364,19 +364,20 @@ pub fn process_add_file( let mut full_path = repo_path.join(&relative_path); if !full_path.is_file() { - // Fix for Windows CLI // util::fs::path_relative_to_dir can fail if the capitalization of the input path differs from what it is in the working directory // TODO: is there ever a situation where process_add_file will be called on a path that doesn't exist? That will be propogated as an error here - log::debug!("file {:?} was not found. Checking for Windows CLI path", full_path); + log::debug!( + "file {:?} was not found. Checking for Windows CLI path", + full_path + ); let canon_repo_path = dunce::canonicalize(repo_path)?; let cli_path = util::fs::path_relative_to_dir(path, &canon_repo_path)?; - + if cli_path.is_file() { relative_path = cli_path; full_path = canon_repo_path.join(&relative_path); } else { - // If it's not a file - no need to add it // We handle directories by traversing the parents of files below log::debug!("file is not a file - skipping add on {:?}", full_path); diff --git a/src/lib/src/util/fs.rs b/src/lib/src/util/fs.rs index a8375d6e0..d9268f6fd 100644 --- a/src/lib/src/util/fs.rs +++ b/src/lib/src/util/fs.rs @@ -1351,7 +1351,12 @@ pub fn path_relative_to_dir( let mut mut_path = path.to_path_buf(); let mut components: Vec = vec![]; while mut_path.parent().is_some() { - log::debug!("Comparing {:?} => {:?} => {:?}", path, mut_path.parent(), dir); + log::debug!( + "Comparing {:?} => {:?} => {:?}", + path, + mut_path.parent(), + dir + ); if let Some(filename) = mut_path.file_name() { if mut_path != dir { components.push(PathBuf::from(filename)); @@ -1382,7 +1387,12 @@ pub fn path_relative_to_canon_dir( let mut mut_path = path.to_path_buf(); let mut components: Vec = vec![]; while mut_path.parent().is_some() { - log::debug!("Comparing {:?} => {:?} => {:?}", path, mut_path.parent(), dir); + log::debug!( + "Comparing {:?} => {:?} => {:?}", + path, + mut_path.parent(), + dir + ); if let Some(filename) = mut_path.file_name() { if mut_path != dir { components.push(PathBuf::from(filename));