|
|
@ -72,7 +72,6 @@ pub struct SourceRegistryConfig { |
|
|
|
pub registry_name: String, |
|
|
|
pub registry_name: String, |
|
|
|
/// Path of CSV file with log of when each crate version was published.
|
|
|
|
/// Path of CSV file with log of when each crate version was published.
|
|
|
|
pub publish_history_csv: PathBuf, |
|
|
|
pub publish_history_csv: PathBuf, |
|
|
|
pub index_url: String, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[derive(Deserialize, Debug, Clone)] |
|
|
|
#[derive(Deserialize, Debug, Clone)] |
|
|
@ -145,7 +144,7 @@ pub struct PublishLogRow { |
|
|
|
pub commit: String, |
|
|
|
pub commit: String, |
|
|
|
pub author: String, |
|
|
|
pub author: String, |
|
|
|
pub time: DateTime<Utc>, |
|
|
|
pub time: DateTime<Utc>, |
|
|
|
// pub unix_nanos: u64,
|
|
|
|
pub unix_nanos: u64, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
struct CsvSetup { |
|
|
|
struct CsvSetup { |
|
|
@ -753,11 +752,7 @@ fn parse_manifests( |
|
|
|
|
|
|
|
|
|
|
|
trace!("extracting Cargo.toml from .crate targz archive"); |
|
|
|
trace!("extracting Cargo.toml from .crate targz archive"); |
|
|
|
let decoder = flate2::read::GzDecoder::new(&dot_crate_bytes[..]); |
|
|
|
let decoder = flate2::read::GzDecoder::new(&dot_crate_bytes[..]); |
|
|
|
let manifest_files = extract_manifest_files_from_tar(decoder) |
|
|
|
let manifest_files = extract_manifest_files_from_tar(decoder)?; |
|
|
|
.map_err(|err| { |
|
|
|
|
|
|
|
error!(%crate_name, vers = %index_meta.vers, ?err, "failed to extract manifest files"); |
|
|
|
|
|
|
|
err |
|
|
|
|
|
|
|
})?; |
|
|
|
|
|
|
|
if manifest_files.cargo_lock.is_none() { |
|
|
|
if manifest_files.cargo_lock.is_none() { |
|
|
|
debug!(%crate_name, %version, "Cargo.lock not present in .crate archive"); |
|
|
|
debug!(%crate_name, %version, "Cargo.lock not present in .crate archive"); |
|
|
|
} |
|
|
|
} |
|
|
@ -816,13 +811,9 @@ fn parse_manifests( |
|
|
|
fn edit_dep_registries( |
|
|
|
fn edit_dep_registries( |
|
|
|
dep_key: &str, |
|
|
|
dep_key: &str, |
|
|
|
manifest: &mut toml_edit::Document, |
|
|
|
manifest: &mut toml_edit::Document, |
|
|
|
config: &Config, |
|
|
|
src_registry_name: &str, |
|
|
|
|
|
|
|
dst_registry_name: &str, |
|
|
|
) -> Result<(), Error> { |
|
|
|
) -> Result<(), Error> { |
|
|
|
let src_registry_name = config.src.registry_name.as_str(); |
|
|
|
|
|
|
|
let dst_registry_name = config.dst.registry_name.as_str(); |
|
|
|
|
|
|
|
let src_index_url = config.src.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 Some(deps) = manifest.get_mut(dep_key).and_then(|item| item.as_table_like_mut()) else { |
|
|
|
trace!("missing key in manifest toml: {}", dep_key); |
|
|
|
trace!("missing key in manifest toml: {}", dep_key); |
|
|
|
return Ok(()) |
|
|
|
return Ok(()) |
|
|
@ -830,20 +821,15 @@ fn edit_dep_registries( |
|
|
|
|
|
|
|
|
|
|
|
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 }; |
|
|
|
|
|
|
|
if t.contains_key("registry-index") { |
|
|
|
|
|
|
|
warn!(dep_name = ?k, "dep table contains registry-index key!"); |
|
|
|
|
|
|
|
} |
|
|
|
if let Some(registry_item) = t.get_mut("registry") { |
|
|
|
if let Some(registry_item) = t.get_mut("registry") { |
|
|
|
if registry_item.as_str().unwrap_or("") == src_registry_name { |
|
|
|
if registry_item.as_str().unwrap_or("") == src_registry_name { |
|
|
|
trace!(dep_name = ?k, %dep_key, ?src_registry_name, ?dst_registry_name, "modifying registry in Cargo.toml"); |
|
|
|
trace!(dep_name = ?k, %dep_key, ?src_registry_name, ?dst_registry_name, "modifying registry in Cargo.toml"); |
|
|
|
*registry_item = toml_edit::value(dst_registry_name); |
|
|
|
*registry_item = toml_edit::value(dst_registry_name); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if let Some(registry_index_item) = t.get_mut("registry-index") { |
|
|
|
|
|
|
|
if registry_index_item.as_str().unwrap_or("") == src_index_url { |
|
|
|
|
|
|
|
trace!(dep_name = ?k, %dep_key, ?src_index_url, ?dst_index_url, "modifying registry-index in Cargo.toml"); |
|
|
|
|
|
|
|
*registry_index_item = toml_edit::value(dst_index_url); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
@ -880,9 +866,9 @@ fn prepare_source_dir_for_publish(config: &Config, meta: &mut VersionMeta) -> Re |
|
|
|
let source_dir = meta.source_dir(); |
|
|
|
let source_dir = meta.source_dir(); |
|
|
|
let mut modified_manifest = meta.manifest_files.cargo_toml_orig.parse::<toml_edit::Document>()?; |
|
|
|
let mut modified_manifest = meta.manifest_files.cargo_toml_orig.parse::<toml_edit::Document>()?; |
|
|
|
|
|
|
|
|
|
|
|
edit_dep_registries("dependencies", &mut modified_manifest, &config)?; |
|
|
|
edit_dep_registries("dependencies", &mut modified_manifest, &config.src.registry_name, &config.dst.registry_name)?; |
|
|
|
edit_dep_registries("dev-dependencies", &mut modified_manifest, &config)?; |
|
|
|
edit_dep_registries("dev-dependencies", &mut modified_manifest, &config.src.registry_name, &config.dst.registry_name)?; |
|
|
|
edit_dep_registries("build-dependencies", &mut modified_manifest, &config)?; |
|
|
|
edit_dep_registries("build-dependencies", &mut modified_manifest, &config.src.registry_name, &config.dst.registry_name)?; |
|
|
|
|
|
|
|
|
|
|
|
edit_publish_registry_if_present(&mut modified_manifest, &config.src.registry_name, &config.dst.registry_name)?; |
|
|
|
edit_publish_registry_if_present(&mut modified_manifest, &config.src.registry_name, &config.dst.registry_name)?; |
|
|
|
|
|
|
|
|
|
|
@ -1045,17 +1031,10 @@ fn main() -> Result<(), Error> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let mut publish_log = read_publish_log_csv(&config.src.publish_history_csv)?; |
|
|
|
let mut publish_log = read_publish_log_csv(&config.src.publish_history_csv)?; |
|
|
|
publish_log.sort_by_key(|x| x.time); |
|
|
|
publish_log.sort_by_key(|x| x.unix_nanos); |
|
|
|
assert!(!publish_log.is_empty()); |
|
|
|
assert!(!publish_log.is_empty()); |
|
|
|
info!(n_rows = publish_log.len(), "parsed publish log csv"); |
|
|
|
info!(n_rows = publish_log.len(), "parsed publish log csv"); |
|
|
|
|
|
|
|
|
|
|
|
if let Some(filter) = config.compile_filter()? { |
|
|
|
|
|
|
|
publish_log.retain(|x| { |
|
|
|
|
|
|
|
filter.is_match(&x.crate_name) |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
info!(n_filtered_rows = publish_log.len(), "filtered publish log"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let krates = rt.block_on(get_index_metas(&config))?; |
|
|
|
let krates = rt.block_on(get_index_metas(&config))?; |
|
|
|
|
|
|
|
|
|
|
|
let mut manifests = parse_manifests(&config, krates)?; |
|
|
|
let mut manifests = parse_manifests(&config, krates)?; |
|
|
|