From 624a5609277eafa5679004c3adff55fe49539874 Mon Sep 17 00:00:00 2001 From: Kevin Matthes <92332892+kevinmatthes@users.noreply.github.com> Date: Sun, 16 Jul 2023 18:26:00 +0200 Subject: [PATCH 1/4] Changed ::= comment-changes: work on entire commit message instead of certain part --- src/changelog/comment_changes.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/changelog/comment_changes.rs b/src/changelog/comment_changes.rs index 80b52ebf..740d1598 100644 --- a/src/changelog/comment_changes.rs +++ b/src/changelog/comment_changes.rs @@ -296,11 +296,15 @@ impl Logic { } if let Ok(commit) = repository.find_commit(oid) { - if let Some(message) = if self.cli.body { - commit.body() - } else { - commit.summary() - } { + if let Some(message) = commit.message() { + let (summary, body) = + message.split_once('\n').unwrap_or((message, "")); + let message = if self.cli.body { + body.trim() + } else { + summary.trim() + }; + if let Some((category, change)) = self.harvest_message(message) { From ce656010cc351b5b096b2de793db3cfddab198e6 Mon Sep 17 00:00:00 2001 From: Kevin Matthes <92332892+kevinmatthes@users.noreply.github.com> Date: Sun, 16 Jul 2023 18:46:01 +0200 Subject: [PATCH 2/4] Added ::= comment-changes: ``--force`` mode --- src/changelog/comment_changes.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/changelog/comment_changes.rs b/src/changelog/comment_changes.rs index 740d1598..554ed308 100644 --- a/src/changelog/comment_changes.rs +++ b/src/changelog/comment_changes.rs @@ -50,6 +50,10 @@ pub struct CommentChanges { #[arg(long, short = 'C')] fallback_category: Option, + /// Whether to enforce the fragment creation. + #[arg(long, short = 'F')] + force: bool, + /// The heading's level in the resulting fragment. #[arg( default_value = "3", @@ -109,6 +113,7 @@ impl CommentChanges { depth: None, extension: FragmentExportFormat::Rst, fallback_category: None, + force: false, heading: 3, keep_a_changelog: false, link: Vec::new(), @@ -299,16 +304,25 @@ impl Logic { if let Some(message) = commit.message() { let (summary, body) = message.split_once('\n').unwrap_or((message, "")); - let message = if self.cli.body { - body.trim() - } else { - summary.trim() - }; if let Some((category, change)) = - self.harvest_message(message) + self.harvest_message(if self.cli.body { + body.trim() + } else { + summary.trim() + }) { Self::insert(&mut result, category, change); + } else if self.cli.force { + if let Some((category, change)) = + self.harvest_message(if self.cli.body { + summary.trim() + } else { + body.trim() + }) + { + Self::insert(&mut result, category, change); + } } } } else { From 8fe8d8585ea6fd88e275349ad0f65e6c6484876c Mon Sep 17 00:00:00 2001 From: Kevin Matthes <92332892+kevinmatthes@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:39:34 +0200 Subject: [PATCH 3/4] Update comment_changes.rs --- src/changelog/comment_changes.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/changelog/comment_changes.rs b/src/changelog/comment_changes.rs index 554ed308..38300829 100644 --- a/src/changelog/comment_changes.rs +++ b/src/changelog/comment_changes.rs @@ -195,7 +195,9 @@ impl Logic { } fn harvest_message(&self, message: &str) -> Option<(String, String)> { - if let Some((category, change)) = + if message.is_empty() { + None + } else if let Some((category, change)) = message.trim().split_once(&self.cli.delimiter) { let category = category.trim().to_string(); From 823147295dfb70eda793c4b276f72a9867a4a566 Mon Sep 17 00:00:00 2001 From: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 16 Jul 2023 17:41:00 +0000 Subject: [PATCH 4/4] Create summary of recent changes --- changelog.d/20230716_174100_GitHub_Actions_337-2.ron | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 changelog.d/20230716_174100_GitHub_Actions_337-2.ron diff --git a/changelog.d/20230716_174100_GitHub_Actions_337-2.ron b/changelog.d/20230716_174100_GitHub_Actions_337-2.ron new file mode 100644 index 00000000..dce4916d --- /dev/null +++ b/changelog.d/20230716_174100_GitHub_Actions_337-2.ron @@ -0,0 +1,11 @@ +( + references: {}, + changes: { + "Added": [ + "comment-changes: ``--force`` mode", + ], + "Changed": [ + "comment-changes: work on entire commit message instead of certain part", + ], + }, +)