mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 12:24:15 +00:00
Make from_rev take an owned value (#3631)
## Summary We always clone internally, and in most case we're already passing `&String`.
This commit is contained in:
parent
47f4114a1b
commit
18b095ce28
4 changed files with 9 additions and 9 deletions
|
|
@ -54,17 +54,17 @@ enum RefspecStrategy {
|
|||
impl GitReference {
|
||||
/// Creates a [`GitReference`] from an arbitrary revision string, which could represent a
|
||||
/// branch, tag, commit, or named ref.
|
||||
pub fn from_rev(rev: &str) -> Self {
|
||||
pub fn from_rev(rev: String) -> Self {
|
||||
if rev.starts_with("refs/") {
|
||||
Self::NamedRef(rev.to_owned())
|
||||
} else if looks_like_commit_hash(rev) {
|
||||
Self::NamedRef(rev)
|
||||
} else if looks_like_commit_hash(&rev) {
|
||||
if rev.len() == 40 {
|
||||
Self::FullCommit(rev.to_owned())
|
||||
Self::FullCommit(rev)
|
||||
} else {
|
||||
Self::BranchOrTagOrCommit(rev.to_owned())
|
||||
Self::BranchOrTagOrCommit(rev)
|
||||
}
|
||||
} else {
|
||||
Self::BranchOrTag(rev.to_owned())
|
||||
Self::BranchOrTag(rev)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ impl TryFrom<Url> for GitUrl {
|
|||
.rsplit_once('@')
|
||||
.map(|(prefix, suffix)| (prefix.to_string(), suffix.to_string()))
|
||||
{
|
||||
reference = GitReference::from_rev(&suffix);
|
||||
reference = GitReference::from_rev(suffix);
|
||||
url.set_path(&prefix);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue