mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Remove usages of verbatim URL in URL resolver (#4221)
## Summary Should be no behavior changes, but one piece of technical debt I noticed left over in the URL resolver. We already have structured paths, so we shouldn't need to compare verbatim URLs.
This commit is contained in:
parent
fd52fe74ce
commit
0c1dcb797a
3 changed files with 130 additions and 232 deletions
|
@ -5,7 +5,7 @@ use thiserror::Error;
|
|||
use url::{ParseError, Url};
|
||||
|
||||
use pep508_rs::{Pep508Url, UnnamedRequirementUrl, VerbatimUrl, VerbatimUrlError};
|
||||
use uv_git::{GitUrl, OidParseError};
|
||||
use uv_git::{GitReference, GitSha, GitUrl, OidParseError};
|
||||
|
||||
use crate::{ArchiveInfo, DirInfo, DirectUrl, VcsInfo, VcsKind};
|
||||
|
||||
|
@ -175,6 +175,17 @@ pub struct ParsedPathUrl {
|
|||
pub editable: bool,
|
||||
}
|
||||
|
||||
impl ParsedPathUrl {
|
||||
/// Construct a [`ParsedPathUrl`] from a path requirement source.
|
||||
pub fn from_source(path: PathBuf, editable: bool, url: Url) -> Self {
|
||||
Self {
|
||||
url,
|
||||
path,
|
||||
editable,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A Git repository URL.
|
||||
///
|
||||
/// Examples:
|
||||
|
@ -186,6 +197,22 @@ pub struct ParsedGitUrl {
|
|||
pub subdirectory: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl ParsedGitUrl {
|
||||
/// Construct a [`ParsedGitUrl`] from a Git requirement source.
|
||||
pub fn from_source(
|
||||
repository: Url,
|
||||
reference: GitReference,
|
||||
precise: Option<GitSha>,
|
||||
subdirectory: Option<PathBuf>,
|
||||
) -> Self {
|
||||
let mut url = GitUrl::new(repository, reference);
|
||||
if let Some(precise) = precise {
|
||||
url = url.with_precise(precise);
|
||||
}
|
||||
Self { url, subdirectory }
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Url> for ParsedGitUrl {
|
||||
type Error = ParsedUrlError;
|
||||
|
||||
|
@ -219,6 +246,16 @@ pub struct ParsedArchiveUrl {
|
|||
pub subdirectory: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl ParsedArchiveUrl {
|
||||
/// Construct a [`ParsedArchiveUrl`] from a URL requirement source.
|
||||
pub fn from_source(location: Url, subdirectory: Option<PathBuf>) -> Self {
|
||||
Self {
|
||||
url: location,
|
||||
subdirectory,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Url> for ParsedArchiveUrl {
|
||||
fn from(url: Url) -> Self {
|
||||
let subdirectory = get_subdirectory(&url);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue