diff --git a/src/handlers/assign.rs b/src/handlers/assign.rs index cb5e2c5c0..80b17b5c5 100644 --- a/src/handlers/assign.rs +++ b/src/handlers/assign.rs @@ -90,6 +90,7 @@ fn get_repo_workqueue(ctx: &Context, repo: &str) -> Arc Ok(Some(AssignInput::Opened { draft: event.issue.draft, })), + IssuesAction::Reopened => Ok(Some(AssignInput::Reopened { + draft: event.issue.draft, + })), IssuesAction::Closed => Ok(Some(AssignInput::Closed)), IssuesAction::ReadyForReview => Ok(Some(AssignInput::ReadyForReview)), IssuesAction::Unlabeled { label: Some(label) } @@ -191,6 +195,40 @@ pub(super) async fn handle_input( // the PR has been marked as being ready for review. assign_command.as_ref().is_some_and(|a| a != GHOST_ACCOUNT) } + AssignInput::Reopened { draft: false } => { + if let Some(community_reviews) = &config.community_reviews + && assign_command.is_none() + { + // There are no current assignees, add the community review label + // + // No need to worry about approvals that may have happend between + // the time the PR was closed and this re-opening as GitHub doesn't + // allow approving a closed PR. + if !event.issue.assignees.is_empty() { + event + .issue + .add_labels( + &ctx.github, + vec![github::Label { + name: community_reviews.label.to_string(), + }], + ) + .await?; + } + false + } else { + // We have historically done nothing to do for normal PRs, even if there + // are no current assignee + false + } + } + AssignInput::Reopened { draft: true } => { + // We have historically done nothing for non-community reviewed PR, so continue to do nothing. + // + // As for community reviewed PRs they are only handled when the PR is not in draft (handled by + // ready for review below) + false + } AssignInput::ReadyForReview => { if let Some(community_reviews) = &config.community_reviews && assign_command.is_none()