Skip to content

Commit

Permalink
Fix publishing to crates.io with -Z sparse-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
arlosi committed Jul 6, 2022
1 parent c0bbd42 commit 132afd3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
}

Expand Down

0 comments on commit 132afd3

Please sign in to comment.