in guppy/src/graph/summaries/package_set.rs [730:784]
fn source_matches(
package_source: PackageSource<'_>,
third_party_source: &ThirdPartySource,
registry_names_to_urls: &HashMap<&'a str, &'a str>,
) -> bool {
match (package_source, third_party_source) {
(PackageSource::Workspace(_), _) => {
// third-party sources can't match a workspace package
false
}
(PackageSource::Path(package_path), ThirdPartySource::Path(summary_path)) => {
package_path == summary_path
}
(PackageSource::Path(_), _) => false,
(PackageSource::External(external), ThirdPartySource::Url(summary_url)) => {
external == summary_url
}
(external, _) => {
let external_source = match external.parse_external() {
Some(external_source) => external_source,
None => {
// The only way this can match is with the ThirdPartySource::Url constraint
// above.
return false;
}
};
match (external_source, third_party_source) {
(
ExternalSource::Registry(external_registry_url),
ThirdPartySource::Registry(Some(summary_registry_name)),
) => {
let &url = registry_names_to_urls
.get(summary_registry_name.as_str())
.expect("all names were already obtained in new()");
url == external_registry_url
}
(
ExternalSource::Registry(external_registry),
ThirdPartySource::Registry(None),
) => external_registry == ExternalSource::CRATES_IO_URL,
(
ExternalSource::Git {
repository, req, ..
},
ThirdPartySource::Git {
repo: summary_repo,
req: summary_req,
},
) => repository == summary_repo && summary_req.as_git_req() == req,
_ => false,
}
}
}
}