Skip to content

Commit 6c5b3a9

Browse files
committed
Improve a major change handling of concerns and auto-close
1 parent f72b997 commit 6c5b3a9

File tree

1 file changed

+41
-13
lines changed

1 file changed

+41
-13
lines changed

src/handlers/major_change.rs

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ pub(super) async fn handle_input(
208208
if event.issue.labels().contains(&Label {
209209
name: config.second_label.to_string(),
210210
}) {
211-
// Re-schedule acceptence job to automaticaly close the MCP
212-
schedule_acceptence_job(ctx, config, &event.issue).await?;
211+
// Re-schedule acceptance job to automaticaly close the MCP
212+
schedule_acceptance_job(ctx, config, &event.issue).await?;
213213

214214
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)
215215
} else {
@@ -267,12 +267,31 @@ pub(super) async fn handle_command(
267267
return Ok(());
268268
}
269269

270-
let zulip_msg = format!(
271-
"@*{}*: Proposal [#{}]({}) has been seconded, and will be approved in 10 days if no objections are raised.",
272-
config.zulip_ping,
273-
issue.number,
274-
event.html_url().unwrap()
275-
);
270+
let has_concerns = if let Some(concerns_label) = &config.concerns_label {
271+
issue.labels().iter().any(|l| &l.name == concerns_label)
272+
} else {
273+
false
274+
};
275+
276+
let waiting_period = config.waiting_period.unwrap_or(10);
277+
278+
let zulip_msg = if !has_concerns {
279+
format!(
280+
"@*{}*: Proposal [#{}]({}) has been seconded, and will be approved in {} days if no objections are raised.",
281+
config.zulip_ping,
282+
issue.number,
283+
event.html_url().unwrap(),
284+
waiting_period,
285+
)
286+
} else {
287+
format!(
288+
"@*{}*: Proposal [#{}]({}) has been seconded, but there are unresolved concerns preventing approval, use `@{} resolve concern-name` in the GitHub thread to resolve them.",
289+
config.zulip_ping,
290+
issue.number,
291+
event.html_url().unwrap(),
292+
&ctx.username,
293+
)
294+
};
276295

277296
handle(
278297
ctx,
@@ -285,13 +304,15 @@ pub(super) async fn handle_command(
285304
.await
286305
.context("unable to process second command")?;
287306

288-
// Schedule acceptence job to automaticaly close the MCP
289-
schedule_acceptence_job(ctx, config, issue).await?;
307+
if !has_concerns {
308+
// Schedule acceptance job to automaticaly close the MCP
309+
schedule_acceptance_job(ctx, config, issue).await?;
310+
}
290311

291312
Ok(())
292313
}
293314

294-
async fn schedule_acceptence_job(
315+
async fn schedule_acceptance_job(
295316
ctx: &Context,
296317
config: &MajorChangeConfig,
297318
issue: &Issue,
@@ -477,7 +498,7 @@ impl Job for MajorChangeAcceptenceJob {
477498
match process_seconded(&ctx, &major_change, now).await {
478499
Ok(()) => {
479500
tracing::info!(
480-
"{}: major change ({:?}) as been accepted, remove from the queue",
501+
"{}: major change ({:?}) as been accepted",
481502
self.name(),
482503
&major_change,
483504
);
@@ -556,7 +577,14 @@ async fn process_seconded(
556577
issue
557578
.post_comment(
558579
&ctx.github,
559-
"The final comment period is now complete, this major change is now accepted.\n\nAs the automated representative, I would like to thank the author for their work and everyone else who contributed to this major change proposal."
580+
&*format!(
581+
"The final comment period is now complete, this major change is now **accepted**.\
582+
\
583+
As the automated representative, I would like to thank the author for their work and everyone else who contributed to this major change proposal.\
584+
\
585+
*If you think this major change shouldn't have been accepted, feel free to remove the `{}` label and reopen this issue.*",
586+
&config.accept_label,
587+
),
560588
)
561589
.await
562590
.context("unable to post the acceptance comment")?;

0 commit comments

Comments
 (0)