Skip to content

Commit ae3ba9d

Browse files
committed
Review feedback
1 parent 2a5bebe commit ae3ba9d

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

crates/cache-key/src/canonical_url.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,14 @@ impl RepositoryUrl {
107107
pub fn new(url: &Url) -> RepositoryUrl {
108108
let mut url = CanonicalUrl::new(url).0;
109109

110-
// Clone to avoid borrow checker issues
111-
let immutable_url = url.clone();
112-
113110
// If a Git URL ends in a reference (like a branch, tag, or commit), remove it.
114111
if url.scheme().starts_with("git+") {
115-
if let Some((prefix, _)) = immutable_url.path().rsplit_once('@') {
116-
url.set_path(prefix);
112+
if let Some(prefix) = url
113+
.path()
114+
.rsplit_once('@')
115+
.map(|(prefix, _suffix)| prefix.to_string())
116+
{
117+
url.set_path(&prefix);
117118
}
118119
}
119120

crates/uv-git/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ impl TryFrom<Url> for GitUrl {
6262
url.set_fragment(None);
6363
url.set_query(None);
6464

65-
// Clone to avoid borrow checker issues
66-
let immutable_url = url.clone();
67-
6865
// If the URL ends with a reference, like `https://git.example.com/[email protected]`,
6966
// extract it.
7067
let mut reference = GitReference::DefaultBranch;
71-
if let Some((prefix, rev)) = immutable_url.path().rsplit_once('@') {
72-
reference = GitReference::from_rev(rev);
73-
url.set_path(prefix);
68+
if let Some((prefix, suffix)) = url
69+
.path()
70+
.rsplit_once('@')
71+
.map(|(prefix, suffix)| (prefix.to_string(), suffix.to_string()))
72+
{
73+
reference = GitReference::from_rev(&suffix);
74+
url.set_path(&prefix);
7475
}
7576

7677
let precise = if let GitReference::FullCommit(rev) = &reference {

0 commit comments

Comments
 (0)