Fix publishing to crates.io with -Z sparse-registry

This commit is contained in:
Arlo Siemsen 2022-07-06 14:20:59 -05:00
parent c0bbd42ce5
commit 132afd3f1b

View file

@ -196,10 +196,6 @@ fn verify_dependencies(
if super::check_dep_has_version(dep, true)? {
continue;
}
// Allow publishing to crates.io with index.crates.io as a source replacement.
if registry_src.is_default_registry() && dep.source_id().is_default_registry() {
continue;
}
// TomlManifest::prepare_for_publish will rewrite the dependency
// to be just the `version` field.
if dep.source_id() != registry_src {
@ -535,6 +531,13 @@ fn registry(
None
};
let handle = http_handle(config)?;
// Workaround for the sparse+https://index.crates.io replacement index. Use the non-replaced
// source_id so that the original (github) url is used when publishing a crate.
let sid = if sid.is_default_registry() {
SourceId::crates_io(config)?
} else {
sid
};
Ok((Registry::new_handle(api_host, token, handle), reg_cfg, sid))
}