Loading tools/changelogger/Cargo.lock +1 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", "once_cell", "ordinal", "pretty_assertions", "serde", Loading tools/changelogger/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ opt-level = 0 [dependencies] anyhow = "1.0.57" clap = { version = "~3.2.1", features = ["derive"] } once_cell = "1.15.0" ordinal = "0.3.2" serde = { version = "1", features = ["derive"]} serde_json = "1" Loading tools/changelogger/src/render.rs +13 −6 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use crate::entry::{ChangeSet, ChangelogEntries, ChangelogEntry}; use anyhow::{bail, Context, Result}; use clap::Parser; use once_cell::sync::Lazy; use ordinal::Ordinal; use serde::Serialize; use smithy_rs_tool_common::changelog::{ Loading Loading @@ -35,10 +36,16 @@ pub const EXAMPLE_ENTRY: &str = r#" pub const USE_UPDATE_CHANGELOGS: &str = "<!-- Do not manually edit this file. Use the `changelogger` tool. -->"; fn maintainers() -> Vec<&'static str> { static MAINTAINERS: Lazy<Vec<String>> = Lazy::new(|| { include_str!("../smithy-rs-maintainers.txt") .lines() .map(|name| name.to_ascii_lowercase()) .collect() }); fn is_maintainer(name: &str) -> bool { let name_lower = name.to_ascii_lowercase(); MAINTAINERS.iter().any(|name| *name == name_lower) } #[derive(Parser, Debug, Eq, PartialEq)] Loading Loading @@ -181,8 +188,8 @@ fn render_entry(entry: &HandAuthoredEntry, mut out: &mut String) { .map(|t| t.to_string()) .chain(entry.references.iter().map(to_md_link)) .collect::<Vec<_>>(); if !maintainers().contains(&entry.author.to_ascii_lowercase().as_str()) { references.push(format!("@{}", entry.author.to_ascii_lowercase())); if !is_maintainer(&entry.author) { references.push(format!("@{}", entry.author)); }; if !references.is_empty() { write!(meta, "({}) ", references.join(", ")).unwrap(); Loading Loading @@ -345,8 +352,8 @@ fn render(entries: &[ChangelogEntry], release_header: &str) -> (String, String) let mut external_contribs = entries .iter() .filter_map(|entry| entry.hand_authored().map(|e| e.author.to_ascii_lowercase())) .filter(|author| !maintainers().contains(&author.as_str())) .filter_map(|entry| entry.hand_authored().map(|e| &e.author)) .filter(|author| !is_maintainer(author)) .collect::<Vec<_>>(); external_contribs.sort(); external_contribs.dedup(); Loading Loading @@ -375,7 +382,7 @@ fn render(entries: &[ChangelogEntry], release_header: &str) -> (String, String) contribution_references.dedup(); let contribution_references = contribution_references.as_slice().join(", "); out.push_str("- @"); out.push_str(&contributor_handle); out.push_str(contributor_handle); if !contribution_references.is_empty() { write!(&mut out, " ({})", contribution_references) // The `Write` implementation for `String` is infallible, Loading tools/changelogger/tests/e2e_test.rs +1 −1 Original line number Diff line number Diff line Loading @@ -432,7 +432,7 @@ author = "rcoh" message = "Fourth change - client" references = ["smithy-rs#4"] meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" } author = "rcoh" author = "LukeMathWalker" "#; let tmp_dir = TempDir::new().unwrap(); let source_path = tmp_dir.path().join("source.toml"); Loading Loading
tools/changelogger/Cargo.lock +1 −0 Original line number Diff line number Diff line Loading @@ -87,6 +87,7 @@ version = "0.1.0" dependencies = [ "anyhow", "clap", "once_cell", "ordinal", "pretty_assertions", "serde", Loading
tools/changelogger/Cargo.toml +1 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ opt-level = 0 [dependencies] anyhow = "1.0.57" clap = { version = "~3.2.1", features = ["derive"] } once_cell = "1.15.0" ordinal = "0.3.2" serde = { version = "1", features = ["derive"]} serde_json = "1" Loading
tools/changelogger/src/render.rs +13 −6 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use crate::entry::{ChangeSet, ChangelogEntries, ChangelogEntry}; use anyhow::{bail, Context, Result}; use clap::Parser; use once_cell::sync::Lazy; use ordinal::Ordinal; use serde::Serialize; use smithy_rs_tool_common::changelog::{ Loading Loading @@ -35,10 +36,16 @@ pub const EXAMPLE_ENTRY: &str = r#" pub const USE_UPDATE_CHANGELOGS: &str = "<!-- Do not manually edit this file. Use the `changelogger` tool. -->"; fn maintainers() -> Vec<&'static str> { static MAINTAINERS: Lazy<Vec<String>> = Lazy::new(|| { include_str!("../smithy-rs-maintainers.txt") .lines() .map(|name| name.to_ascii_lowercase()) .collect() }); fn is_maintainer(name: &str) -> bool { let name_lower = name.to_ascii_lowercase(); MAINTAINERS.iter().any(|name| *name == name_lower) } #[derive(Parser, Debug, Eq, PartialEq)] Loading Loading @@ -181,8 +188,8 @@ fn render_entry(entry: &HandAuthoredEntry, mut out: &mut String) { .map(|t| t.to_string()) .chain(entry.references.iter().map(to_md_link)) .collect::<Vec<_>>(); if !maintainers().contains(&entry.author.to_ascii_lowercase().as_str()) { references.push(format!("@{}", entry.author.to_ascii_lowercase())); if !is_maintainer(&entry.author) { references.push(format!("@{}", entry.author)); }; if !references.is_empty() { write!(meta, "({}) ", references.join(", ")).unwrap(); Loading Loading @@ -345,8 +352,8 @@ fn render(entries: &[ChangelogEntry], release_header: &str) -> (String, String) let mut external_contribs = entries .iter() .filter_map(|entry| entry.hand_authored().map(|e| e.author.to_ascii_lowercase())) .filter(|author| !maintainers().contains(&author.as_str())) .filter_map(|entry| entry.hand_authored().map(|e| &e.author)) .filter(|author| !is_maintainer(author)) .collect::<Vec<_>>(); external_contribs.sort(); external_contribs.dedup(); Loading Loading @@ -375,7 +382,7 @@ fn render(entries: &[ChangelogEntry], release_header: &str) -> (String, String) contribution_references.dedup(); let contribution_references = contribution_references.as_slice().join(", "); out.push_str("- @"); out.push_str(&contributor_handle); out.push_str(contributor_handle); if !contribution_references.is_empty() { write!(&mut out, " ({})", contribution_references) // The `Write` implementation for `String` is infallible, Loading
tools/changelogger/tests/e2e_test.rs +1 −1 Original line number Diff line number Diff line Loading @@ -432,7 +432,7 @@ author = "rcoh" message = "Fourth change - client" references = ["smithy-rs#4"] meta = { "breaking" = false, "tada" = false, "bug" = false, "target" = "client" } author = "rcoh" author = "LukeMathWalker" "#; let tmp_dir = TempDir::new().unwrap(); let source_path = tmp_dir.path().join("source.toml"); Loading