mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Factor out a function for building a NewCrate.
Co-Authored-By: Tor Hovland <55164+torhovland@users.noreply.github.com>
This commit is contained in:
parent
7f2079838a
commit
8771230eb8
@ -321,14 +321,11 @@ fn verify_dependencies(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transmit(
|
pub(crate) fn prepare_transmit(
|
||||||
gctx: &GlobalContext,
|
gctx: &GlobalContext,
|
||||||
pkg: &Package,
|
pkg: &Package,
|
||||||
tarball: &File,
|
|
||||||
registry: &mut Registry,
|
|
||||||
registry_id: SourceId,
|
registry_id: SourceId,
|
||||||
dry_run: bool,
|
) -> CargoResult<NewCrate> {
|
||||||
) -> CargoResult<()> {
|
|
||||||
let deps = pkg
|
let deps = pkg
|
||||||
.dependencies()
|
.dependencies()
|
||||||
.iter()
|
.iter()
|
||||||
@ -410,12 +407,6 @@ fn transmit(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not upload if performing a dry run
|
|
||||||
if dry_run {
|
|
||||||
gctx.shell().warn("aborting upload due to dry run")?;
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
let deps_set = deps
|
let deps_set = deps
|
||||||
.iter()
|
.iter()
|
||||||
.map(|dep| dep.name.clone())
|
.map(|dep| dep.name.clone())
|
||||||
@ -447,30 +438,46 @@ fn transmit(
|
|||||||
None => BTreeMap::new(),
|
None => BTreeMap::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Ok(NewCrate {
|
||||||
|
name: pkg.name().to_string(),
|
||||||
|
vers: pkg.version().to_string(),
|
||||||
|
deps,
|
||||||
|
features: string_features,
|
||||||
|
authors: authors.clone(),
|
||||||
|
description: description.clone(),
|
||||||
|
homepage: homepage.clone(),
|
||||||
|
documentation: documentation.clone(),
|
||||||
|
keywords: keywords.clone(),
|
||||||
|
categories: categories.clone(),
|
||||||
|
readme: readme_content,
|
||||||
|
readme_file: readme.clone(),
|
||||||
|
repository: repository.clone(),
|
||||||
|
license: license.clone(),
|
||||||
|
license_file: license_file.clone(),
|
||||||
|
badges: badges.clone(),
|
||||||
|
links: links.clone(),
|
||||||
|
rust_version,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn transmit(
|
||||||
|
gctx: &GlobalContext,
|
||||||
|
pkg: &Package,
|
||||||
|
tarball: &File,
|
||||||
|
registry: &mut Registry,
|
||||||
|
registry_id: SourceId,
|
||||||
|
dry_run: bool,
|
||||||
|
) -> CargoResult<()> {
|
||||||
|
let new_crate = prepare_transmit(gctx, pkg, registry_id)?;
|
||||||
|
|
||||||
|
// Do not upload if performing a dry run
|
||||||
|
if dry_run {
|
||||||
|
gctx.shell().warn("aborting upload due to dry run")?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let warnings = registry
|
let warnings = registry
|
||||||
.publish(
|
.publish(&new_crate, tarball)
|
||||||
&NewCrate {
|
|
||||||
name: pkg.name().to_string(),
|
|
||||||
vers: pkg.version().to_string(),
|
|
||||||
deps,
|
|
||||||
features: string_features,
|
|
||||||
authors: authors.clone(),
|
|
||||||
description: description.clone(),
|
|
||||||
homepage: homepage.clone(),
|
|
||||||
documentation: documentation.clone(),
|
|
||||||
keywords: keywords.clone(),
|
|
||||||
categories: categories.clone(),
|
|
||||||
readme: readme_content,
|
|
||||||
readme_file: readme.clone(),
|
|
||||||
repository: repository.clone(),
|
|
||||||
license: license.clone(),
|
|
||||||
license_file: license_file.clone(),
|
|
||||||
badges: badges.clone(),
|
|
||||||
links: links.clone(),
|
|
||||||
rust_version,
|
|
||||||
},
|
|
||||||
tarball,
|
|
||||||
)
|
|
||||||
.with_context(|| format!("failed to publish to registry at {}", registry.host()))?;
|
.with_context(|| format!("failed to publish to registry at {}", registry.host()))?;
|
||||||
|
|
||||||
if !warnings.invalid_categories.is_empty() {
|
if !warnings.invalid_categories.is_empty() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user