summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/external_crates/crate_health/src/reports.rs30
1 files changed, 27 insertions, 3 deletions
diff --git a/tools/external_crates/crate_health/src/reports.rs b/tools/external_crates/crate_health/src/reports.rs
index ec2d099de..488bc589f 100644
--- a/tools/external_crates/crate_health/src/reports.rs
+++ b/tools/external_crates/crate_health/src/reports.rs
@@ -15,8 +15,8 @@
use std::{fmt::Display, fs::write, path::Path, str::from_utf8};
use crate::{
- crates_with_multiple_versions, crates_with_single_version, Crate, CrateCollection,
- NameAndVersionMap, NamedAndVersioned, VersionMatch, VersionPair,
+ crates_with_multiple_versions, crates_with_single_version, CompatibleVersionPair, Crate,
+ CrateCollection, NameAndVersionMap, NamedAndVersioned, VersionMatch, VersionPair,
};
use anyhow::Result;
@@ -132,6 +132,30 @@ impl<'template> ReportEngine<'template> {
}
Ok(self.tt.render("table", &table)?)
}
+ pub fn migratable_table<'a>(
+ &self,
+ crate_pairs: impl Iterator<Item = CompatibleVersionPair<'a, Crate>>,
+ ) -> Result<String> {
+ let mut table = Table::new(&[&"Crate", &"Old Version", &"New Version", &"Path"]);
+ for crate_pair in crate_pairs {
+ let source = crate_pair.source;
+ let dest = crate_pair.dest;
+ let dest_version = if source.version() == dest.version() {
+ "".to_string()
+ } else {
+ dest.version().to_string()
+ };
+ table.add_row(&[
+ &linkify(&source.name(), &source.crates_io_url()),
+ &source.version().to_string(),
+ &dest_version,
+ &source.aosp_url().map_or(format!("{}", source.relpath().display()), |url| {
+ linkify(&source.relpath().display(), &url)
+ }),
+ ]);
+ }
+ Ok(self.tt.render("table", &table)?)
+ }
pub fn migration_ineligible_table<'a>(
&self,
crates: impl Iterator<Item = &'a Crate>,
@@ -248,7 +272,7 @@ impl<'template> ReportEngine<'template> {
output_path: &impl AsRef<Path>,
) -> Result<()> {
let mr = MigrationReport {
- migratable: self.table(m.migratable().map(|pair| pair.source))?,
+ migratable: self.migratable_table(m.migratable())?,
eligible: self.migration_eligible_table(m.eligible_but_not_migratable())?,
ineligible: self.migration_ineligible_table(m.ineligible())?,
superfluous: self.table(m.superfluous().map(|(_nv, krate)| krate))?,