|
|
@ -723,20 +723,11 @@ struct Node<'a> { |
|
|
|
// begin.elapsed(),
|
|
|
|
// begin.elapsed(),
|
|
|
|
// );
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
fn parse_manifests( |
|
|
|
fn parse_one_manifest( |
|
|
|
config: &Config, |
|
|
|
config: &Config, |
|
|
|
crate_versions: HashMap<String, Vec<IndexMeta>>, |
|
|
|
crate_name: &str, |
|
|
|
) -> Result<HashMap<String, Vec<VersionMeta>>, Error> { |
|
|
|
index_meta: IndexMeta, |
|
|
|
let begin = Instant::now(); |
|
|
|
) -> Result<VersionMeta, Error> { |
|
|
|
|
|
|
|
|
|
|
|
let out: HashMap<String, Vec<VersionMeta>> = crate_versions |
|
|
|
|
|
|
|
.into_par_iter() |
|
|
|
|
|
|
|
// .into_iter()
|
|
|
|
|
|
|
|
.map(|(crate_name, versions)| -> Result<(String, Vec<VersionMeta>), Error> { |
|
|
|
|
|
|
|
let begin = Instant::now(); |
|
|
|
|
|
|
|
debug!(%crate_name, "parsing manifests"); |
|
|
|
|
|
|
|
let mut version_metas = Vec::new(); |
|
|
|
|
|
|
|
for index_meta in versions { |
|
|
|
|
|
|
|
let version = index_meta.vers.clone(); |
|
|
|
let version = index_meta.vers.clone(); |
|
|
|
trace!(%crate_name, %version, "processing crate version"); |
|
|
|
trace!(%crate_name, %version, "processing crate version"); |
|
|
|
let dot_crate_path = config.src.crate_files_dir |
|
|
|
let dot_crate_path = config.src.crate_files_dir |
|
|
@ -794,7 +785,7 @@ fn parse_manifests( |
|
|
|
// // .other_options(["--frozen"].into_iter().map(|x| x.to_owned()).collect::<Vec<_>>())
|
|
|
|
// // .other_options(["--frozen"].into_iter().map(|x| x.to_owned()).collect::<Vec<_>>())
|
|
|
|
// .exec()?;
|
|
|
|
// .exec()?;
|
|
|
|
|
|
|
|
|
|
|
|
version_metas.push(VersionMeta { |
|
|
|
Ok(VersionMeta { |
|
|
|
index_meta, |
|
|
|
index_meta, |
|
|
|
manifest_files, |
|
|
|
manifest_files, |
|
|
|
dot_crate_path, |
|
|
|
dot_crate_path, |
|
|
@ -803,11 +794,44 @@ fn parse_manifests( |
|
|
|
tmp, |
|
|
|
tmp, |
|
|
|
modified_manifest_toml: None, |
|
|
|
modified_manifest_toml: None, |
|
|
|
// meta,
|
|
|
|
// meta,
|
|
|
|
}); |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn parse_manifests( |
|
|
|
|
|
|
|
config: &Config, |
|
|
|
|
|
|
|
crate_versions: HashMap<String, Vec<IndexMeta>>, |
|
|
|
|
|
|
|
) -> Result<HashMap<String, Vec<VersionMeta>>, Error> { |
|
|
|
|
|
|
|
let begin = Instant::now(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let out: HashMap<String, Vec<VersionMeta>> = crate_versions |
|
|
|
|
|
|
|
.into_par_iter() |
|
|
|
|
|
|
|
// .into_iter()
|
|
|
|
|
|
|
|
.filter_map(|(crate_name, versions)| -> Option<(String, Vec<VersionMeta>)> { |
|
|
|
|
|
|
|
let begin = Instant::now(); |
|
|
|
|
|
|
|
debug!(%crate_name, "parsing manifests"); |
|
|
|
|
|
|
|
let mut version_metas = Vec::new(); |
|
|
|
|
|
|
|
let mut n_err = 0; |
|
|
|
|
|
|
|
for index_meta in versions { |
|
|
|
|
|
|
|
let version = index_meta.vers.clone(); |
|
|
|
|
|
|
|
match parse_one_manifest(config, &crate_name, index_meta) { |
|
|
|
|
|
|
|
Ok(meta) => { |
|
|
|
|
|
|
|
version_metas.push(meta); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Err(err) => { |
|
|
|
|
|
|
|
error!(?err, %crate_name, %version, "failed to parse manifest; skipping"); |
|
|
|
|
|
|
|
n_err += 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
debug!(%crate_name, n_err, "parsed {} manifests in {:?}", version_metas.len(), begin.elapsed()); |
|
|
|
|
|
|
|
if version_metas.is_empty() { |
|
|
|
|
|
|
|
warn!(%crate_name, n_err, "parsed zero manifests successfully for crate!"); |
|
|
|
|
|
|
|
None |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Some((crate_name, version_metas)) |
|
|
|
} |
|
|
|
} |
|
|
|
debug!(%crate_name, "parsed {} manifests in {:?}", version_metas.len(), begin.elapsed()); |
|
|
|
}).collect(); |
|
|
|
Ok((crate_name, version_metas)) |
|
|
|
|
|
|
|
}).collect::<Result<_, Error>>()?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
info!("parsed crate version manifests in {:?}", begin.elapsed()); |
|
|
|
info!("parsed crate version manifests in {:?}", begin.elapsed()); |
|
|
|
|
|
|
|
|
|
|
@ -822,6 +846,11 @@ fn parse_manifests( |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// conditional dep tables aren't handled right:
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// [target.'cfg(not(target_env = "msvc"))'.dependencies]
|
|
|
|
|
|
|
|
// dep-one = { version = "0.1.0", registry = "old-registry" }
|
|
|
|
|
|
|
|
//
|
|
|
|
fn edit_dep_registries( |
|
|
|
fn edit_dep_registries( |
|
|
|
dep_key: &str, |
|
|
|
dep_key: &str, |
|
|
|
manifest: &mut toml_edit::Document, |
|
|
|
manifest: &mut toml_edit::Document, |
|
|
@ -832,11 +861,17 @@ fn edit_dep_registries( |
|
|
|
let src_index_url = config.src.index_url.as_str(); |
|
|
|
let src_index_url = config.src.index_url.as_str(); |
|
|
|
let dst_index_url = config.dst.index_url.as_str(); |
|
|
|
let dst_index_url = config.dst.index_url.as_str(); |
|
|
|
|
|
|
|
|
|
|
|
let Some(deps) = manifest.get_mut(dep_key).and_then(|item| item.as_table_like_mut()) else { |
|
|
|
let dep_key_ends_with = format!(".{dep_key}"); |
|
|
|
trace!("missing key in manifest toml: {}", dep_key); |
|
|
|
|
|
|
|
return Ok(()) |
|
|
|
let it = manifest.iter_mut() |
|
|
|
}; |
|
|
|
.filter(|(k, v)| { |
|
|
|
|
|
|
|
k == dep_key || k.ends_with(&dep_key_ends_with) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (outer_k, outer_v) in it { |
|
|
|
|
|
|
|
let Some(deps) = outer_v.as_table_like_mut() else { |
|
|
|
|
|
|
|
anyhow::bail!("failed to cast deps item as table"); |
|
|
|
|
|
|
|
}; |
|
|
|
for (k, v) in deps.iter_mut() { |
|
|
|
for (k, v) in deps.iter_mut() { |
|
|
|
let Some(t) = v.as_table_like_mut() else { continue }; |
|
|
|
let Some(t) = v.as_table_like_mut() else { continue }; |
|
|
|
|
|
|
|
|
|
|
@ -854,6 +889,7 @@ fn edit_dep_registries( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -978,9 +1014,11 @@ fn cargo_publish_modified_source_dir(config: &Config, meta: &VersionMeta) -> Res |
|
|
|
let stdout = std::str::from_utf8(&output.stdout).unwrap_or("utf8err"); |
|
|
|
let stdout = std::str::from_utf8(&output.stdout).unwrap_or("utf8err"); |
|
|
|
let stderr = std::str::from_utf8(&output.stderr).unwrap_or("utf8err"); |
|
|
|
let stderr = std::str::from_utf8(&output.stderr).unwrap_or("utf8err"); |
|
|
|
error!(exit_status = ?output.status, "cargo publish error!\nstdout:\n{}\nstderr:\n:{}\n\n", stdout, stderr); |
|
|
|
error!(exit_status = ?output.status, "cargo publish error!\nstdout:\n{}\nstderr:\n:{}\n\n", stdout, stderr); |
|
|
|
|
|
|
|
if !stderr.contains("already exists") { |
|
|
|
debug!("cargo publish error - original Cargo.toml:\n***\n{}\n***", meta.manifest_files.cargo_toml_orig); |
|
|
|
debug!("cargo publish error - original Cargo.toml:\n***\n{}\n***", meta.manifest_files.cargo_toml_orig); |
|
|
|
debug!("cargo publish error - modified Cargo.toml:\n***\n{}\n***", meta.modified_manifest_toml.as_ref().unwrap()); |
|
|
|
debug!("cargo publish error - modified Cargo.toml:\n***\n{}\n***", meta.modified_manifest_toml.as_ref().unwrap()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
info!(name = %meta.index_meta.name, vers = %meta.index_meta.vers, "finished cargo publish in {:?}", begin.elapsed()); |
|
|
|
info!(name = %meta.index_meta.name, vers = %meta.index_meta.vers, "finished cargo publish in {:?}", begin.elapsed()); |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|