Combine fetch and resolve steps in Git resolver (#5886)

## Summary

Whenever we call `resolve`, we immediately call `fetch` after. And in
some cases `resolve` actually calls `fetch` internally. It seems a lot
simpler to just merge these into one method that returns a `Fetch`
(which itself contains the fully-resolved URL).

Closes https://github.com/astral-sh/uv/issues/5876.
This commit is contained in:
Charlie Marsh 2024-08-07 18:35:05 -04:00 committed by GitHub
parent 7523673f39
commit bc1d7764e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 79 deletions

View file

@ -1121,29 +1121,12 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
return Err(Error::HashesNotSupportedGit(source.to_string()));
}
// Resolve to a precise Git SHA.
let url = if let Some(url) = self
.build_context
.git()
.resolve(
resource.git,
client.unmanaged.uncached_client().client(),
self.build_context.cache().bucket(CacheBucket::Git),
self.reporter.clone().map(Facade::from),
)
.await?
{
Cow::Owned(url)
} else {
Cow::Borrowed(resource.git)
};
// Fetch the Git repository.
let fetch = self
.build_context
.git()
.fetch(
&url,
resource.git,
client.unmanaged.uncached_client().client(),
self.build_context.cache().bucket(CacheBucket::Git),
self.reporter.clone().map(Facade::from),
@ -1208,29 +1191,12 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
return Err(Error::HashesNotSupportedGit(source.to_string()));
}
// Resolve to a precise Git SHA.
let url = if let Some(url) = self
.build_context
.git()
.resolve(
resource.git,
client.unmanaged.uncached_client().client(),
self.build_context.cache().bucket(CacheBucket::Git),
self.reporter.clone().map(Facade::from),
)
.await?
{
Cow::Owned(url)
} else {
Cow::Borrowed(resource.git)
};
// Fetch the Git repository.
let fetch = self
.build_context
.git()
.fetch(
&url,
resource.git,
client.unmanaged.uncached_client().client(),
self.build_context.cache().bucket(CacheBucket::Git),
self.reporter.clone().map(Facade::from),