Skip to content

Commit f9caea4

Browse files
authored
fix(automator): honour releases.generate_notes config when creating GitHub releases (#144)
Fixes a silent bug where release-regent always passed generate_release_notes: false to the GitHub API regardless of the releases.generate_notes setting in release-regent.toml, making the documented default of true have no effect at runtime. closes #141 ## What Changed - Added `generate_release_notes: bool` field to `AutomatorConfig` (default `false`, preserving existing runtime behaviour). - Replaced the hardcoded `false` literal in `CreateReleaseParams` inside `ReleaseAutomator::automate()` with `self.config.generate_release_notes`. - Threaded `repo_config.releases.generate_notes` into `AutomatorConfig` in `lib.rs::handle_release_pr_merged` so the value flows from config file to API call. - Changed `default_generate_notes()` in `config.rs` from `true` to `false` so the schema default matches the runtime default, eliminating the contradiction. ## Why `AutomatorConfig` had no field for this setting, so there was no path from the `releases.generate_notes` config key to the GitHub API call. Users who relied on the documented default (`true`) or who explicitly set `generate_notes = true` would never get GitHub's auto-generated release notes. Users who set `false` got the same behaviour as users who set `true`, making the config key entirely inert. ## How The fix follows the existing pattern for other `AutomatorConfig` fields: add the field to the struct, supply a sensible default, and set it from `repo_config` at the construction site in `handle_release_pr_merged`. No new abstractions were introduced. ## Testing Evidence - **Test Coverage:** Added two new async tests in `release_automator_tests.rs`: `test_automate_generate_release_notes_true_sets_flag_in_api_call` and `test_automate_generate_release_notes_false_clears_flag_in_api_call`. Both inspect the `CreateReleaseParams` recorded by the test double to assert the correct flag value. - **Test Results:** All 39 `release_automator` tests pass; no regressions. - **Manual Testing:** Not applicable — the fix is fully covered by the unit test double. ## Reviewer Guidance - Confirm the new default (`false`) is the right choice; users who previously relied on the (broken) documented default of `true` will now need to set `generate_notes = true` explicitly in their config — consider whether a changelog note or migration hint is warranted. - The `releases.generate_notes` field in `ReleasesConfig` and the new `AutomatorConfig::generate_release_notes` field are intentionally separate: one is the user-facing config type, the other is the internal automator config. - No breaking changes to public API; `AutomatorConfig::default()` behaviour is unchanged (`generate_release_notes: false`).
2 parents ec8da57 + 03aee03 commit f9caea4

6 files changed

Lines changed: 82 additions & 5 deletions

File tree

crates/core/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ pub struct ReleasesConfig {
249249
}
250250

251251
fn default_generate_notes() -> bool {
252-
true
252+
false
253253
}
254254

255255
impl Default for ReleasesConfig {

crates/core/src/config_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn test_default_configuration() {
8181
assert_eq!(config.core.branches.main, "main");
8282
assert!(!config.release_pr.draft);
8383
assert!(!config.releases.draft);
84-
assert!(config.releases.generate_notes);
84+
assert!(!config.releases.generate_notes);
8585
assert_eq!(config.error_handling.max_retries, 5);
8686
assert!(config.notifications.enabled);
8787
assert!(matches!(

crates/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ where
345345
&repo_config.release_pr.body_template,
346346
),
347347
version_prefix: repo_config.core.version_prefix.clone(),
348+
generate_release_notes: repo_config.releases.generate_notes,
348349
};
349350

350351
match ReleaseAutomator::new(

crates/core/src/release_automator.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ pub struct AutomatorConfig {
8585
///
8686
/// Defaults to `"v"`.
8787
pub version_prefix: String,
88+
89+
/// Whether to ask GitHub to auto-generate release notes from commits and
90+
/// pull requests when creating the GitHub release.
91+
///
92+
/// When `true` the `generate_release_notes` flag in the GitHub API
93+
/// request is set, causing GitHub to append its own notes to the body.
94+
/// When `false` (the default) only the changelog extracted from the PR
95+
/// body is used.
96+
///
97+
/// Defaults to `false`.
98+
pub generate_release_notes: bool,
8899
}
89100

90101
impl Default for AutomatorConfig {
@@ -93,6 +104,7 @@ impl Default for AutomatorConfig {
93104
branch_prefix: "release".to_string(),
94105
changelog_header: "## Changelog".to_string(),
95106
version_prefix: "v".to_string(),
107+
generate_release_notes: false,
96108
}
97109
}
98110
}
@@ -211,7 +223,7 @@ impl<'a, G: GitHubOperations + Send + Sync> ReleaseAutomator<'a, G> {
211223
body: Some(changelog),
212224
draft: false,
213225
prerelease: is_prerelease,
214-
generate_release_notes: false,
226+
generate_release_notes: self.config.generate_release_notes,
215227
target_commitish: Some(merge_sha),
216228
},
217229
)

crates/core/src/release_automator_tests.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,3 +1407,67 @@ async fn test_automate_custom_version_prefix_creates_tag_with_prefix() {
14071407
assert_eq!(tags.len(), 1);
14081408
assert_eq!(tags[0].0, "release-1.2.3");
14091409
}
1410+
1411+
// ─────────────────────────────────────────────────────────────────────────────
1412+
// generate_release_notes config tests
1413+
// ─────────────────────────────────────────────────────────────────────────────
1414+
1415+
#[tokio::test]
1416+
async fn test_automate_generate_release_notes_true_sets_flag_in_api_call() {
1417+
// When AutomatorConfig::generate_release_notes is true, the API request
1418+
// must pass generate_release_notes: true so GitHub generates release notes.
1419+
let github = TestGitHub::new();
1420+
let config = AutomatorConfig {
1421+
generate_release_notes: true,
1422+
..AutomatorConfig::default()
1423+
};
1424+
let automator = ReleaseAutomator::new(config, &github);
1425+
1426+
let event = make_release_pr_event(
1427+
"release/v1.2.3",
1428+
"deadbeef1234567890deadbeef1234567890abcd",
1429+
"## Changelog\n\n- feat: add widget [abc123def456789012345678901234567890abcd]\n",
1430+
);
1431+
1432+
automator
1433+
.automate("testorg", "testrepo", &event, "corr-001")
1434+
.await
1435+
.unwrap();
1436+
1437+
let releases = github.created_releases().await;
1438+
assert_eq!(releases.len(), 1);
1439+
assert!(
1440+
releases[0].generate_release_notes,
1441+
"generate_release_notes must be true when configured as true"
1442+
);
1443+
}
1444+
1445+
#[tokio::test]
1446+
async fn test_automate_generate_release_notes_false_clears_flag_in_api_call() {
1447+
// When AutomatorConfig::generate_release_notes is false (the default),
1448+
// the API request must pass generate_release_notes: false.
1449+
let github = TestGitHub::new();
1450+
let config = AutomatorConfig {
1451+
generate_release_notes: false,
1452+
..AutomatorConfig::default()
1453+
};
1454+
let automator = ReleaseAutomator::new(config, &github);
1455+
1456+
let event = make_release_pr_event(
1457+
"release/v1.2.3",
1458+
"deadbeef1234567890deadbeef1234567890abcd",
1459+
"## Changelog\n\n- feat: add widget [abc123def456789012345678901234567890abcd]\n",
1460+
);
1461+
1462+
automator
1463+
.automate("testorg", "testrepo", &event, "corr-001")
1464+
.await
1465+
.unwrap();
1466+
1467+
let releases = github.created_releases().await;
1468+
assert_eq!(releases.len(), 1);
1469+
assert!(
1470+
!releases[0].generate_release_notes,
1471+
"generate_release_notes must be false when configured as false"
1472+
);
1473+
}

docs/specs/operations/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ assignees = []
9797
[releases]
9898
draft = false
9999
prerelease = false
100-
generate_notes = true
100+
generate_notes = false # Opt in to GitHub-generated notes; default is false so the custom changelog is used
101101
cleanup_branches = true
102102

103103
# Versioning strategy
@@ -518,7 +518,7 @@ labels = ["release", "automated"]
518518
[releases]
519519
draft = false
520520
prerelease = false
521-
generate_notes = true
521+
generate_notes = false # Opt in to GitHub-generated notes; default is false so the custom changelog is used
522522
cleanup_branches = true
523523

524524
[versioning]

0 commit comments

Comments
 (0)