Skip to content

Commit

Permalink
fix: Fixed path strip panic on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Feb 10, 2024
1 parent fc75139 commit 996beab
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions crates/codspeed/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ pub fn get_git_relative_path<P>(abs_path: P) -> PathBuf
where
P: AsRef<Path>,
{
let abs_path = abs_path.as_ref();
match abs_path
.canonicalize()
.and_then(|p| get_parent_git_repo_path(&p))
{
Ok(repo_path) => abs_path.strip_prefix(repo_path).unwrap().to_path_buf(),
Err(_) => abs_path.to_path_buf(),
if let Ok(abs_path) = abs_path.as_ref().canonicalize() {
if let Ok(repo_path) = get_parent_git_repo_path(&abs_path) {
return abs_path
.strip_prefix(repo_path)
.expect("Repository path is malformed.")
.to_path_buf();
}
}

abs_path.as_ref().to_path_buf()
}

/// Fixes spaces around `::` created by stringify!($function).
Expand Down

0 comments on commit 996beab

Please sign in to comment.