From 80edabdb40876076c2b99490eaf76ec047c499af Mon Sep 17 00:00:00 2001 From: MarcoIeni <11428655+MarcoIeni@users.noreply.github.com> Date: Sun, 14 Jul 2024 22:24:09 +0200 Subject: [PATCH 1/2] fix(release): don't try to parse changelog if it doesn't exist --- crates/release_plz/src/config.rs | 3 +++ crates/release_plz_core/src/command/release.rs | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/crates/release_plz/src/config.rs b/crates/release_plz/src/config.rs index fbbffb2d7e..3f975de32c 100644 --- a/crates/release_plz/src/config.rs +++ b/crates/release_plz/src/config.rs @@ -223,6 +223,9 @@ impl From for release_plz_core::ReleaseConfig { ) .with_release(release); + if let Some(changelog_update) = value.changelog_update { + cfg = cfg.with_changelog_update(changelog_update); + } if let Some(changelog_path) = value.changelog_path { cfg = cfg.with_changelog_path(to_utf8_pathbuf(changelog_path).unwrap()); } diff --git a/crates/release_plz_core/src/command/release.rs b/crates/release_plz_core/src/command/release.rs index 1254488e76..a30fef4e5e 100644 --- a/crates/release_plz_core/src/command/release.rs +++ b/crates/release_plz_core/src/command/release.rs @@ -238,6 +238,9 @@ pub struct ReleaseConfig { /// High-level toggle to process this package or ignore it release: bool, changelog_path: Option, + /// Whether this package has a changelog that release-plz update or not. + /// Default: `true`. + changelog_update: bool, } impl ReleaseConfig { @@ -281,6 +284,11 @@ impl ReleaseConfig { self } + pub fn with_changelog_update(mut self, changelog_update: bool) -> Self { + self.changelog_update = changelog_update; + self + } + pub fn publish(&self) -> &PublishConfig { &self.publish } @@ -301,6 +309,7 @@ impl Default for ReleaseConfig { features: vec![], release: true, changelog_path: None, + changelog_update: true, } } } @@ -736,7 +745,12 @@ fn release_body(req: &ReleaseRequest, package: &Package, changelog: &str) -> Str ) } +/// Return an empty string if not found. fn last_changelog_entry(req: &ReleaseRequest, package: &Package) -> String { + let changelog_update = req.get_package_config(&package.name).changelog_update; + if !changelog_update { + return String::new(); + } let changelog_path = req.changelog_path(package); match changelog_parser::last_changes(&changelog_path) { Ok(Some(changes)) => changes, From f84de52ef35ad5c47a470fe0a4ddac49bbc87550 Mon Sep 17 00:00:00 2001 From: MarcoIeni <11428655+MarcoIeni@users.noreply.github.com> Date: Sun, 14 Jul 2024 22:27:13 +0200 Subject: [PATCH 2/2] wip --- crates/release_plz_core/src/command/release.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/release_plz_core/src/command/release.rs b/crates/release_plz_core/src/command/release.rs index a30fef4e5e..c59f462b34 100644 --- a/crates/release_plz_core/src/command/release.rs +++ b/crates/release_plz_core/src/command/release.rs @@ -238,7 +238,7 @@ pub struct ReleaseConfig { /// High-level toggle to process this package or ignore it release: bool, changelog_path: Option, - /// Whether this package has a changelog that release-plz update or not. + /// Whether this package has a changelog that release-plz updates or not. /// Default: `true`. changelog_update: bool, }