Skip to content

Commit

Permalink
Better diff.
Browse files Browse the repository at this point in the history
  • Loading branch information
torhovland committed May 22, 2024
1 parent 592124d commit a045177
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions src/cargo/ops/registry/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,58 @@ fn verify_dependencies(
Ok(())
}

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, true)?;

// 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
.publish(&new_crate, tarball)
.with_context(|| format!("failed to publish to registry at {}", registry.host()))?;

if !warnings.invalid_categories.is_empty() {
let msg = format!(
"the following are not valid category slugs and were \
ignored: {}. Please see https://crates.io/category_slugs \
for the list of all category slugs. \
",
warnings.invalid_categories.join(", ")
);
gctx.shell().warn(&msg)?;
}

if !warnings.invalid_badges.is_empty() {
let msg = format!(
"the following are not valid badges and were ignored: {}. \
Either the badge type specified is unknown or a required \
attribute is missing. Please see \
https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata \
for valid badge types and their required attributes.",
warnings.invalid_badges.join(", ")
);
gctx.shell().warn(&msg)?;
}

if !warnings.other.is_empty() {
for msg in warnings.other {
gctx.shell().warn(&msg)?;
}
}

Ok(())
}

pub(crate) fn prepare_transmit(
gctx: &GlobalContext,
pkg: &Package,
Expand Down Expand Up @@ -467,55 +519,3 @@ pub(crate) fn prepare_transmit(
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, true)?;

// 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
.publish(&new_crate, tarball)
.with_context(|| format!("failed to publish to registry at {}", registry.host()))?;

if !warnings.invalid_categories.is_empty() {
let msg = format!(
"the following are not valid category slugs and were \
ignored: {}. Please see https://crates.io/category_slugs \
for the list of all category slugs. \
",
warnings.invalid_categories.join(", ")
);
gctx.shell().warn(&msg)?;
}

if !warnings.invalid_badges.is_empty() {
let msg = format!(
"the following are not valid badges and were ignored: {}. \
Either the badge type specified is unknown or a required \
attribute is missing. Please see \
https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata \
for valid badge types and their required attributes.",
warnings.invalid_badges.join(", ")
);
gctx.shell().warn(&msg)?;
}

if !warnings.other.is_empty() {
for msg in warnings.other {
gctx.shell().warn(&msg)?;
}
}

Ok(())
}

0 comments on commit a045177

Please sign in to comment.