Don't redact username git for SSH (#13799)

Fixes #13795 specifically by not redacting the username convention `git`
for SSH URLs, though we should never write stars in `uv export`
generally (#13791).
This commit is contained in:
konsti 2025-06-03 16:18:18 +02:00 committed by GitHub
parent 99a4b78af2
commit eb9ad6c8c0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -91,7 +91,10 @@ impl DisplaySafeUrl {
pub fn remove_credentials(&mut self) {
// For URLs that use the `git` convention (i.e., `ssh://git@github.com/...`), avoid dropping the
// username.
if self.0.scheme() == "ssh" && self.0.username() == "git" && self.0.password().is_none() {
if matches!(self.0.scheme(), "git+ssh" | "ssh")
&& self.0.username() == "git"
&& self.0.password().is_none()
{
return;
}
let _ = self.0.set_username("");
@ -180,6 +183,15 @@ fn display_with_redacted_credentials(
return write!(f, "{url}");
}
// For URLs that use the `git` convention (i.e., `ssh://git@github.com/...`), avoid dropping the
// username.
if matches!(url.scheme(), "git+ssh" | "ssh")
&& url.username() == "git"
&& url.password().is_none()
{
return write!(f, "{url}");
}
write!(f, "{}://", url.scheme())?;
if url.username() != "" && url.password().is_some() {