Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite transient path deps in git deps #1458

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions scarb/src/resolver/algorithm/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,35 @@ impl<'a, 'c> PubGrubDependencyProvider<'a, 'c> {

Ok(summaries)
}

fn rewrite_dependency_source_id(
&self,
package_id: PackageId,
dependency: &ManifestDependency,
) -> Result<ManifestDependency, DependencyProviderError> {
// Rewrite path dependencies for git sources.
if package_id.source_id.is_git() && dependency.source_id.is_path() {
let rewritten_dep = ManifestDependency::builder()
.kind(dependency.kind.clone())
.name(dependency.name.clone())
.source_id(package_id.source_id)
.version_req(dependency.version_req.clone())
.build();
// Check if this dependency can be queried from git source.
// E.g. packages below other package's manifest will not be accessible.
if !self
.handle
.block_on(self.registry.query(&rewritten_dep))
.map_err(DependencyProviderError::PackageQueryFailed)?
.is_empty()
{
// If it is, return rewritten dependency.
return Ok(rewritten_dep);
}
};

Ok(dependency.clone())
}
}

impl<'a, 'c> DependencyProvider for PubGrubDependencyProvider<'a, 'c> {
Expand Down Expand Up @@ -249,6 +278,9 @@ impl<'a, 'c> DependencyProvider for PubGrubDependencyProvider<'a, 'c> {
.filtered_full_dependencies(dep_filter)
.cloned()
.map(|dependency| {
let dependency =
self.rewrite_dependency_source_id(summary.package_id, &dependency)?;

let req = VersionReq::from(dependency.version_req.clone());
let dep_name = dependency.name.clone().to_string();
let summaries = self.query(dependency)?;
Expand Down
Loading