From 305044245fa61672a77455fc7a312218b36ce949 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Thu, 24 Oct 2024 14:57:28 -0700 Subject: [PATCH 1/2] tc --- src/git.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/git.rs b/src/git.rs index 477aa43..d627ad6 100644 --- a/src/git.rs +++ b/src/git.rs @@ -1,4 +1,4 @@ -use std::{collections::HashSet, convert::TryFrom, process::Command}; +use std::{collections::HashSet, convert::TryFrom, ffi::OsStr, path::Path, process::Command}; use crate::{ log_utils::{ensure_output, log_files}, @@ -160,14 +160,14 @@ impl VersionControl for Repo { std::str::from_utf8(&output.stdout).context("failed to parse paths_cmd output")?; let files = files .lines() - .map(|s| s.to_string()) - .collect::>(); - let mut files = files.into_iter().collect::>(); + .map(|s| OsStr::new(s)) + .collect::>(); + let mut files = files.into_iter().collect::>(); files.sort(); files .into_iter() - .map(AbsPath::try_from) - .collect::>() + .map(|p: &OsStr| AbsPath::try_from(AsRef::::as_ref(p))) + .collect::>>() } } From 21544e64510066707bc7dabd91ca7d0f2d3843f9 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Fri, 25 Oct 2024 10:09:36 -0700 Subject: [PATCH 2/2] tc --- src/git.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/git.rs b/src/git.rs index d627ad6..e2f4c63 100644 --- a/src/git.rs +++ b/src/git.rs @@ -1,4 +1,4 @@ -use std::{collections::HashSet, convert::TryFrom, ffi::OsStr, path::Path, process::Command}; +use std::{collections::HashSet, convert::TryFrom, process::Command}; use crate::{ log_utils::{ensure_output, log_files}, @@ -160,14 +160,19 @@ impl VersionControl for Repo { std::str::from_utf8(&output.stdout).context("failed to parse paths_cmd output")?; let files = files .lines() - .map(|s| OsStr::new(s)) - .collect::>(); - let mut files = files.into_iter().collect::>(); + .map(|s| s.to_string()) + .collect::>(); + let mut files = files.into_iter().collect::>(); files.sort(); - files + Ok(files .into_iter() - .map(|p: &OsStr| AbsPath::try_from(AsRef::::as_ref(p))) - .collect::>>() + .filter_map(|p| if let Ok(abs_path) = AbsPath::try_from(&p) { + Some(abs_path) + } else { + debug!("Failed to convert path to AbsPath: {}", p); + None + }) + .collect::>()) } }