mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 02:48:17 +00:00
Add parsed URL to PubGrubPackage
(#3426)
Avoid reparsing urls by storing the parsed parts across resolution on `PubGrubPackage`. Part 1 of #3408
This commit is contained in:
parent
5132c6a6e2
commit
0010954ca7
17 changed files with 194 additions and 79 deletions
|
@ -155,15 +155,11 @@ pub(crate) async fn resolve_precise(
|
|||
///
|
||||
/// This method will only return precise URLs for URLs that have already been resolved via
|
||||
/// [`resolve_precise`].
|
||||
pub fn to_precise(url: &Url) -> Option<Url> {
|
||||
let ParsedGitUrl { url, subdirectory } = ParsedGitUrl::try_from(url.clone()).ok()?;
|
||||
pub fn git_url_to_precise(url: GitUrl) -> Option<GitUrl> {
|
||||
let resolved_git_refs = RESOLVED_GIT_REFS.lock().unwrap();
|
||||
let reference = RepositoryReference::new(&url);
|
||||
let precise = resolved_git_refs.get(&reference)?;
|
||||
Some(Url::from(ParsedGitUrl {
|
||||
url: url.with_precise(*precise),
|
||||
subdirectory,
|
||||
}))
|
||||
Some(url.with_precise(*precise))
|
||||
}
|
||||
|
||||
/// Returns `true` if the URLs refer to the same Git commit.
|
||||
|
|
|
@ -2,7 +2,7 @@ pub use archive::Archive;
|
|||
pub use distribution_database::{DistributionDatabase, HttpArchivePointer, LocalArchivePointer};
|
||||
pub use download::LocalWheel;
|
||||
pub use error::Error;
|
||||
pub use git::{is_same_reference, to_precise};
|
||||
pub use git::{git_url_to_precise, is_same_reference};
|
||||
pub use index::{BuiltWheelIndex, RegistryWheelIndex};
|
||||
use pypi_types::{HashDigest, Metadata23};
|
||||
pub use reporter::Reporter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue