Skip to content

Commit 2b47080

Browse files
authored
Merge pull request #2075 from Urgau/major_change-fixes-2
Small fixes for major changes
2 parents 1657187 + 4450cbf commit 2b47080

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/config.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,12 @@ pub(crate) struct MajorChangeConfig {
400400
pub(crate) meeting_label: String,
401401
/// This label signals there are concern(s) about the proposal.
402402
pub(crate) concerns_label: Option<String>,
403-
/// An optional duration (in days) for the waiting period after second for the
404-
/// major change to become automaticaly accepted.
405-
pub(crate) waiting_period: Option<u16>,
403+
/// Waiting period after second for the major change to become accepted.
404+
#[serde(default = "MajorChangeConfig::waiting_period_default")]
405+
pub(crate) waiting_period: u16,
406+
/// Enables automatic closing of the major change when the waiting period is completed.
407+
#[serde(default)]
408+
pub(crate) auto_closing: bool,
406409
/// The Zulip stream ID where the messages about the status of
407410
/// the major changed should be relayed.
408411
pub(crate) zulip_stream: u64,
@@ -417,6 +420,9 @@ impl MajorChangeConfig {
417420
fn accept_label_default() -> String {
418421
String::from("major-change-accepted")
419422
}
423+
fn waiting_period_default() -> u16 {
424+
10
425+
}
420426
}
421427

422428
#[derive(PartialEq, Eq, Debug, serde::Deserialize)]

src/handlers/major_change.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ pub(super) async fn handle_input(
211211
// Re-schedule acceptance job to automaticaly close the MCP
212212
schedule_acceptance_job(ctx, config, &event.issue).await?;
213213

214-
format!("All concerns on the [associated GitHub issue]({}) have been resolved, this proposal is no longer blocked, and will be approved in 10 days if no (new) objections are raised.", event.issue.html_url)
214+
format!("All concerns on the [associated GitHub issue]({}) have been resolved, this proposal is no longer blocked, and will be approved in {} days if no (new) objections are raised.", event.issue.html_url, config.waiting_period)
215215
} else {
216216
format!("All concerns on the [associated GitHub issue]({}) have been resolved, this proposal is no longer blocked.", event.issue.html_url)
217217
},
@@ -273,15 +273,13 @@ pub(super) async fn handle_command(
273273
false
274274
};
275275

276-
let waiting_period = config.waiting_period.unwrap_or(10);
277-
278276
let zulip_msg = if !has_concerns {
279277
format!(
280278
"@*{}*: Proposal [#{}]({}) has been seconded, and will be approved in {} days if no objections are raised.",
281279
config.zulip_ping,
282280
issue.number,
283281
event.html_url().unwrap(),
284-
waiting_period,
282+
config.waiting_period,
285283
)
286284
} else {
287285
format!(
@@ -317,13 +315,13 @@ async fn schedule_acceptance_job(
317315
config: &MajorChangeConfig,
318316
issue: &Issue,
319317
) -> anyhow::Result<()> {
320-
if let Some(waiting_period) = &config.waiting_period {
318+
if config.auto_closing {
321319
let seconded_at = Utc::now();
322320
let accept_at = if issue.repository().full_repo_name() == "rust-lang/triagebot" {
323321
// Hack for the triagebot repo, so we can test more quickly
324322
seconded_at + Duration::minutes(5)
325323
} else {
326-
seconded_at + Duration::days((*waiting_period).into())
324+
seconded_at + Duration::days(config.waiting_period.into())
327325
};
328326

329327
let major_change_seconded = MajorChangeSeconded {
@@ -587,11 +585,11 @@ async fn process_seconded(
587585
.post_comment(
588586
&ctx.github,
589587
&*format!(
590-
"The final comment period is now complete, this major change is now **accepted**.\
591-
\
592-
As the automated representative, I would like to thank the author for their work and everyone else who contributed to this major change proposal.\
593-
\
594-
*If you think this major change shouldn't have been accepted, feel free to remove the `{}` label and reopen this issue.*",
588+
r#"The final comment period is now complete, this major change is now **accepted**.
589+
590+
As the automated representative, I would like to thank the author for their work and everyone else who contributed to this major change proposal.
591+
592+
*If you think this major change shouldn't have been accepted, feel free to remove the `{}` label and reopen this issue.*"#,
595593
&config.accept_label,
596594
),
597595
)

0 commit comments

Comments
 (0)