History

fix: improve headline parsing for git-conventional messages.

It is now case-insensitive, which prevents it from getting tripped up in some cases.

Sebastian Thiel committed 4 years ago

Commit f9daba41 parent 25da30f2 files · +9 −1Browse files

Unified · Split

2 files
  1. cargo-smart-release/src/changelog/parse.rs +8 −1
  2. cargo-smart-release/src/changelog/section/segment.rs +1 −0
cargo-smart-release/src/changelog/parse.rs+8−1
@@ -245,7 +245,14 @@ fn parse_conventional_to_next_section_title( · 244 unmodified lines
245245 "fix", "add", "feat", "revert", "remove", "change", "docs", "perf", "refactor", "other", "style",
246246 ]
247247 .iter()
248− .find(|kind| title.starts_with(section::segment::conventional::as_headline(*kind).unwrap_or(*kind)))
248+ .find(|kind| {
249+ let headline = section::segment::conventional::as_headline(*kind).unwrap_or(*kind);
250+ let common_len = headline.len().min(title.len());
251+ title
252+ .get(..common_len)
253+ .and_then(|t| headline.get(..common_len).map(|h| t.eq_ignore_ascii_case(h)))
254+ .unwrap_or(false)
255+ })
249256 .expect("BUG: this list needs an update too if new kinds of conventional messages are added");
250257
251258 let mut conventional = section::segment::Conventional {
cargo-smart-release/src/changelog/section/segment.rs+1−0
@@ -37,6 +37,7 @@ pub mod conventional { · 36 unmodified lines
3737 "chore" => "Chore",
3838 "test" => "Test",
3939 "refactor" => "Refactor",
40+ "other" => "Other",
4041 "style" => "Style",
4142 _unknown => return None,
4243 })