Unified · Split
| @@ -107,6 +107,7 @@ impl Section { · 106 unmodified lines | ||
| 107 | 107 | mut out: impl std::fmt::Write, |
| 108 | 108 | link_mode: &Linkables, |
| 109 | 109 | components: Components, |
| 110 | + capitalize_commit: bool, | |
| 110 | 111 | ) -> std::fmt::Result { |
| 111 | 112 | match self { |
| 112 | 113 | Section::Verbatim { text, .. } => { |
| @@ -149,7 +150,7 @@ impl Section { · 36 unmodified lines | ||
| 149 | 150 | |
| 150 | 151 | let section_level = *heading_level + 1; |
| 151 | 152 | for segment in segments { |
| 152 | − segment.write_to(section_level, link_mode, components, &mut out)?; | |
| 153 | + segment.write_to(section_level, link_mode, components, capitalize_commit, &mut out)?; | |
| 153 | 154 | } |
| 154 | 155 | if !unknown.is_empty() && components.contains(Components::HTML_TAGS) { |
| 155 | 156 | writeln!(out, "{}", Section::UNKNOWN_TAG_START)?; |
| @@ -181,9 +182,10 @@ impl ChangeLog { · 25 unmodified lines | ||
| 181 | 182 | mut out: impl std::fmt::Write, |
| 182 | 183 | link_mode: &Linkables, |
| 183 | 184 | components: Components, |
| 185 | + capitalize_commit: bool, | |
| 184 | 186 | ) -> std::fmt::Result { |
| 185 | 187 | for section in &self.sections { |
| 186 | − section.write_to(&mut out, link_mode, components)?; | |
| 188 | + section.write_to(&mut out, link_mode, components, capitalize_commit)?; | |
| 187 | 189 | } |
| 188 | 190 | Ok(()) |
| 189 | 191 | } |
| @@ -195,6 +197,7 @@ impl section::Segment { · 5 unmodified lines | ||
| 195 | 197 | section_level: usize, |
| 196 | 198 | link_mode: &Linkables, |
| 197 | 199 | components: Components, |
| 200 | + capitalize_commit: bool, | |
| 198 | 201 | mut out: impl std::fmt::Write, |
| 199 | 202 | ) -> std::fmt::Result { |
| 200 | 203 | let write_html = components.contains(Components::HTML_TAGS); |
| @@ -233,6 +236,11 @@ impl section::Segment { · 32 unmodified lines | ||
| 233 | 236 | for message in messages { |
| 234 | 237 | match message { |
| 235 | 238 | Message::Generated { title, id, body } => { |
| 239 | + let title = if capitalize_commit { | |
| 240 | + capitalize_message_title(title) | |
| 241 | + } else { | |
| 242 | + Cow::Borrowed(title.as_str()) | |
| 243 | + }; | |
| 236 | 244 | if write_html { |
| 237 | 245 | writeln!( |
| 238 | 246 | out, |
| @@ -21,6 +21,7 @@ fn main() -> anyhow::Result<()> { · 20 unmodified lines | ||
| 21 | 21 | no_links, |
| 22 | 22 | without, |
| 23 | 23 | allow_dirty, |
| 24 | + capitalize_commit, | |
| 24 | 25 | } => { |
| 25 | 26 | init_logging(false); |
| 26 | 27 | command::changelog( |
| @@ -31,6 +32,7 @@ fn main() -> anyhow::Result<()> { · 4 unmodified lines | ||
| 31 | 32 | preview: !no_preview, |
| 32 | 33 | dependencies: !no_dependencies, |
| 33 | 34 | generator_segments: names_to_segment_selection(&without)?, |
| 35 | + capitalize_commit, | |
| 34 | 36 | }, |
| 35 | 37 | crates, |
| 36 | 38 | )? |
| @@ -60,6 +62,7 @@ fn main() -> anyhow::Result<()> { · 23 unmodified lines | ||
| 60 | 62 | allow_fully_generated_changelogs, |
| 61 | 63 | no_dependencies, |
| 62 | 64 | no_isolate_dependencies_from_breaking_changes, |
| 65 | + capitalize_commit | |
| 63 | 66 | } => { |
| 64 | 67 | let verbose = execute || verbose; |
| 65 | 68 | init_logging(verbose); |
| @@ -86,6 +89,7 @@ fn main() -> anyhow::Result<()> { · 20 unmodified lines | ||
| 86 | 89 | allow_fully_generated_changelogs, |
| 87 | 90 | changelog_links: !no_changelog_links, |
| 88 | 91 | allow_changelog_github_release: !no_changelog_github_release, |
| 92 | + capitalize_commit, | |
| 89 | 93 | }, |
| 90 | 94 | crates, |
| 91 | 95 | to_bump_spec(bump.as_deref().unwrap_or(DEFAULT_BUMP_SPEC))?, |
| @@ -157,6 +157,10 @@ pub enum SubCommands { · 156 unmodified lines | ||
| 157 | 157 | /// depend on an unpublished version with "--no-validate". |
| 158 | 158 | #[clap(long, help_heading = Some("EXPERT"))] |
| 159 | 159 | ignore_instability: bool, |
| 160 | + | |
| 161 | + /// Automatically capitalize commit message | |
| 162 | + #[clap(long, help_heading = Some("CHANGELOG"))] | |
| 163 | + capitalize_commit: bool, | |
| 160 | 164 | }, |
| 161 | 165 | #[clap(name = "changelog", version = clap::crate_version!())] |
| 162 | 166 | /// Generate changelogs from commit histories, non-destructively. |
| @@ -201,5 +205,9 @@ pub enum SubCommands { · 38 unmodified lines | ||
| 201 | 205 | /// Do not generate links to commits and issues when writing the changelogs. This currently only works for GitHub. |
| 202 | 206 | #[clap(long, help_heading = Some("CUSTOMIZATION"))] |
| 203 | 207 | no_links: bool, |
| 208 | + | |
| 209 | + /// Automatically capitalize commit message | |
| 210 | + #[clap(long, help_heading = Some("CUSTOMIZATION"))] | |
| 211 | + capitalize_commit: bool, | |
| 204 | 212 | }, |
| 205 | 213 | } |
| @@ -18,6 +18,7 @@ pub fn changelog(opts: Options, crates: Vec<String>) -> anyhow::Result<()> { · 17 unmodified lines | ||
| 18 | 18 | dry_run, |
| 19 | 19 | preview, |
| 20 | 20 | no_links, |
| 21 | + capitalize_commit, | |
| 21 | 22 | .. |
| 22 | 23 | } = opts; |
| 23 | 24 | let bump_spec = if dependencies { BumpSpec::Auto } else { BumpSpec::Keep }; |
| @@ -97,6 +98,7 @@ pub fn changelog(opts: Options, crates: Vec<String>) -> anyhow::Result<()> { · 73 unmodified lines | ||
| 97 | 98 | } else { |
| 98 | 99 | Components::all() |
| 99 | 100 | }, |
| 101 | + capitalize_commit, | |
| 100 | 102 | ) |
| 101 | 103 | .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?; |
| 102 | 104 | file.write_all(buf.as_bytes()) |
| @@ -25,6 +25,7 @@ pub mod release { · 24 unmodified lines | ||
| 25 | 25 | pub allow_fully_generated_changelogs: bool, |
| 26 | 26 | pub changelog_links: bool, |
| 27 | 27 | pub allow_changelog_github_release: bool, |
| 28 | + pub capitalize_commit: bool, | |
| 28 | 29 | } |
| 29 | 30 | } |
| 30 | 31 | #[path = "release/mod.rs"] |
| @@ -43,6 +44,7 @@ pub mod changelog { · 12 unmodified lines | ||
| 43 | 44 | // All the segments to generate |
| 44 | 45 | pub generator_segments: segment::Selection, |
| 45 | 46 | pub no_links: bool, |
| 47 | + pub capitalize_commit: bool, | |
| 46 | 48 | } |
| 47 | 49 | } |
| 48 | 50 | #[path = "changelog.rs"] |
| @@ -377,6 +377,7 @@ fn gather_changelog_data<'meta>( · 376 unmodified lines | ||
| 377 | 377 | Options { |
| 378 | 378 | dry_run, |
| 379 | 379 | generator_segments, |
| 380 | + capitalize_commit, | |
| 380 | 381 | .. |
| 381 | 382 | }: Options, |
| 382 | 383 | ) -> anyhow::Result<GatherOutcome<'meta>> { |
| @@ -484,6 +485,7 @@ fn gather_changelog_data<'meta>( · 101 unmodified lines | ||
| 484 | 485 | } else { |
| 485 | 486 | changelog::write::Components::all() |
| 486 | 487 | }, |
| 488 | + capitalize_commit | |
| 487 | 489 | )?; |
| 488 | 490 | lock.with_mut(|file| file.write_all(write_buf.as_bytes()))?; |
| 489 | 491 | *made_change |= previous_content.map(|previous| write_buf != previous).unwrap_or(true); |
| @@ -437,7 +437,7 @@ fn perform_release(ctx: &Context, options: Options, crates: &[Dependency<'_>]) - · 436 unmodified lines | ||
| 437 | 437 | commit_id, |
| 438 | 438 | release_section_by_publishee |
| 439 | 439 | .get(&publishee.name.as_str()) |
| 440 | − .and_then(|s| section_to_string(s, WriteMode::Tag)), | |
| 440 | + .and_then(|s| section_to_string(s, WriteMode::Tag, options.capitalize_commit)), | |
| 441 | 441 | &ctx.base, |
| 442 | 442 | options, |
| 443 | 443 | )? { |
| @@ -449,7 +449,7 @@ fn perform_release(ctx: &Context, options: Options, crates: &[Dependency<'_>]) - · 5 unmodified lines | ||
| 449 | 449 | for (publishee, new_version) in successful_publishees_and_version { |
| 450 | 450 | release_section_by_publishee |
| 451 | 451 | .get(&publishee.name.as_str()) |
| 452 | − .and_then(|s| section_to_string(s, WriteMode::GitHubRelease)) | |
| 452 | + .and_then(|s| section_to_string(s, WriteMode::GitHubRelease, options.capitalize_commit)) | |
| 453 | 453 | .map(|release_notes| github::create_release(publishee, new_version, &release_notes, options, &ctx.base)) |
| 454 | 454 | .transpose()?; |
| 455 | 455 | } |
| @@ -512,7 +512,7 @@ enum WriteMode { · 56 unmodified lines | ||
| 512 | 512 | GitHubRelease, |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | −fn section_to_string(section: &Section, mode: WriteMode) -> Option<String> { | |
| 515 | +fn section_to_string(section: &Section, mode: WriteMode, capitalize_commit: bool) -> Option<String> { | |
| 516 | 516 | let mut b = String::new(); |
| 517 | 517 | section |
| 518 | 518 | .write_to( |
| @@ -522,6 +522,7 @@ fn section_to_string(section: &Section, mode: WriteMode) -> Option<String> { · 3 unmodified lines | ||
| 522 | 522 | WriteMode::Tag => changelog::write::Components::empty(), |
| 523 | 523 | WriteMode::GitHubRelease => changelog::write::Components::DETAIL_TAGS, |
| 524 | 524 | }, |
| 525 | + capitalize_commit, | |
| 525 | 526 | ) |
| 526 | 527 | .ok() |
| 527 | 528 | .map(|_| b) |
| @@ -59,7 +59,7 @@ fn conventional_write_empty_messages() -> Result { · 58 unmodified lines | ||
| 59 | 59 | let log = log.clone(); |
| 60 | 60 | for _round in 1..=2 { |
| 61 | 61 | let mut md = String::new(); |
| 62 | − log.write_to(&mut md, link_mode, changelog::write::Components::all())?; | |
| 62 | + log.write_to(&mut md, link_mode, changelog::write::Components::all(), false)?; | |
| 63 | 63 | insta::assert_snapshot!(md); |
| 64 | 64 | |
| 65 | 65 | let parsed_log = ChangeLog::from_markdown(&md); |
| @@ -72,7 +72,7 @@ fn conventional_write_empty_messages() -> Result { · 6 unmodified lines | ||
| 72 | 72 | ] { |
| 73 | 73 | for section in &log.sections { |
| 74 | 74 | let mut buf = String::new(); |
| 75 | − section.write_to(&mut buf, &changelog::write::Linkables::AsText, *components)?; | |
| 75 | + section.write_to(&mut buf, &changelog::write::Linkables::AsText, *components, false)?; | |
| 76 | 76 | insta::assert_snapshot!(buf); |
| 77 | 77 | } |
| 78 | 78 | } |
| @@ -164,7 +164,7 @@ fn all_section_types_round_trips_lossy() -> Result { · 85 unmodified lines | ||
| 164 | 164 | ] { |
| 165 | 165 | // NOTE: we can't run this a second time as the statistical information will be gone (it was never parsed back) |
| 166 | 166 | let mut md = String::new(); |
| 167 | − log.write_to(&mut md, link_mode, changelog::write::Components::all())?; | |
| 167 | + log.write_to(&mut md, link_mode, changelog::write::Components::all(), false)?; | |
| 168 | 168 | insta::assert_snapshot!(md); |
| 169 | 169 | |
| 170 | 170 | let parsed_log = ChangeLog::from_markdown(&md); |
| @@ -178,7 +178,7 @@ fn all_section_types_round_trips_lossy() -> Result { · 7 unmodified lines | ||
| 178 | 178 | ] { |
| 179 | 179 | for section in &log.sections { |
| 180 | 180 | let mut buf = String::new(); |
| 181 | − section.write_to(&mut buf, &changelog::write::Linkables::AsText, *components)?; | |
| 181 | + section.write_to(&mut buf, &changelog::write::Linkables::AsText, *components, false)?; | |
| 182 | 182 | insta::assert_snapshot!(buf); |
| 183 | 183 | } |
| 184 | 184 | } |