Compare commits

...

2 Commits

  1. 29
      src/publish.rs

29
src/publish.rs

@ -40,6 +40,17 @@ struct Opt {
/// the config file.
#[clap(long, value_name = "REGEX", alias = "filter")]
pub filter_crates: Option<String>,
/// Option to limit the number of crate versions published. If set, when the
/// number is reached the program will exit.
#[clap(long, short = 'n', value_name = "INT")]
pub limit: Option<usize>,
/// Option to skip a number of crate versions at the beginning of the dependency
/// order, for use if resuming. The skipped versions will not count as part of
/// the optional --limit.
#[clap(long, value_name = "INT")]
pub skip: Option<usize>,
}
#[derive(Debug, Clone, Deserialize)]
@ -707,7 +718,7 @@ fn prepare_source_dirs_for_publish(
fn cargo_publish_modified_source_dir(config: &Config, meta: &VersionMeta) -> Result<(), Error> {
let begin = Instant::now();
info!(name = %meta.index_meta.name, vers = %meta.index_meta.vers, "publishing crate version");
debug!(name = %meta.index_meta.name, vers = %meta.index_meta.vers, "publishing crate version");
let index_env_key = format!(
"CARGO_REGISTRIES_{}_INDEX",
config.dst.registry_name.to_case(Case::ScreamingSnake)
@ -728,6 +739,16 @@ fn cargo_publish_modified_source_dir(config: &Config, meta: &VersionMeta) -> Res
args.extend_from_slice(&["--manifest-path", manifest_path_str.as_str()][..]);
args.extend_from_slice(&["--no-verify", "--allow-dirty", "-vv"][..]);
if config.dry_run {
warn!(
name = %meta.index_meta.name,
vers = %meta.index_meta.vers,
cmd = format!("cargo {}", args.join(" ")),
"skipping actual publish cmd: --dry-run mode",
);
return Ok(())
}
debug!(name = %meta.index_meta.name, vers = %meta.index_meta.vers, "executing `cargo {}`", args.join(" "));
let output = std::process::Command::new("cargo")
.env(&index_env_key, &config.dst.index_url)
@ -848,7 +869,11 @@ fn main() -> Result<(), Error> {
.flat_map(|(k, v)| v.iter().map(|m| ((k.as_str(), &m.index_meta.vers), m)))
.collect();
for row in publish_log.iter() {
let skip = opt.skip.unwrap_or(0);
let limit = opt.limit.unwrap_or(publish_log.len());
debug!(skip, limit, n_total_versions = publish_log.len(), "ready to publish!");
for row in publish_log.iter().skip(skip).take(limit) {
let Some(meta) = by_name_vers.remove(&(row.crate_name.as_str(), &row.version)) else {
warn!(
?row,

Loading…
Cancel
Save