Skip to content

Commit 60f2ca3

Browse files
authored
Don't user display empty string for absolute path CWD (#15897)
With the previous order an absolute path would become an empty string.
1 parent 422863f commit 60f2ca3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

crates/uv-fs/src/path.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ impl<T: AsRef<Path>> Simplified for T {
6969
return path.display();
7070
}
7171

72+
// Attempt to strip the current working directory, then the canonicalized current working
73+
// directory, in case they differ.
74+
let path = path.strip_prefix(CWD.simplified()).unwrap_or(path);
75+
7276
if path.as_os_str() == "" {
7377
// Avoid printing an empty string for the current directory
7478
return Path::new(".").display();
7579
}
7680

77-
// Attempt to strip the current working directory, then the canonicalized current working
78-
// directory, in case they differ.
79-
let path = path.strip_prefix(CWD.simplified()).unwrap_or(path);
80-
8181
path.display()
8282
}
8383

crates/uv-workspace/src/dependency_groups.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl IntoIterator for FlatDependencyGroups {
253253
#[derive(Debug, Error)]
254254
#[error("{} has malformed dependency groups", if path.is_empty() && package.is_empty() {
255255
"Project".to_string()
256-
} else if path.is_empty() {
256+
} else if path.is_empty() || path == "." {
257257
format!("Project `{package}`")
258258
} else if package.is_empty() {
259259
format!("`{path}`")

0 commit comments

Comments
 (0)