Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(release): don't try to parse changelog if it doesn't exist #1563

Merged
merged 2 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/release_plz/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ impl From<PackageConfig> 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());
}
Expand Down
14 changes: 14 additions & 0 deletions crates/release_plz_core/src/command/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ pub struct ReleaseConfig {
/// High-level toggle to process this package or ignore it
release: bool,
changelog_path: Option<Utf8PathBuf>,
/// Whether this package has a changelog that release-plz updates or not.
/// Default: `true`.
changelog_update: bool,
}

impl ReleaseConfig {
Expand Down Expand Up @@ -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
}
Expand All @@ -301,6 +309,7 @@ impl Default for ReleaseConfig {
features: vec![],
release: true,
changelog_path: None,
changelog_update: true,
}
}
}
Expand Down Expand Up @@ -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,
Expand Down