Don't user display empty string for absolute path CWD (#15897)

With the previous order an absolute path would become an empty string.
This commit is contained in:
konsti 2025-09-16 19:49:08 +02:00 committed by GitHub
parent 422863ffde
commit 60f2ca3388
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -69,15 +69,15 @@ impl<T: AsRef<Path>> Simplified for T {
return path.display();
}
// Attempt to strip the current working directory, then the canonicalized current working
// directory, in case they differ.
let path = path.strip_prefix(CWD.simplified()).unwrap_or(path);
if path.as_os_str() == "" {
// Avoid printing an empty string for the current directory
return Path::new(".").display();
}
// Attempt to strip the current working directory, then the canonicalized current working
// directory, in case they differ.
let path = path.strip_prefix(CWD.simplified()).unwrap_or(path);
path.display()
}

View file

@ -253,7 +253,7 @@ impl IntoIterator for FlatDependencyGroups {
#[derive(Debug, Error)]
#[error("{} has malformed dependency groups", if path.is_empty() && package.is_empty() {
"Project".to_string()
} else if path.is_empty() {
} else if path.is_empty() || path == "." {
format!("Project `{package}`")
} else if package.is_empty() {
format!("`{path}`")