Skip to content

Commit

Permalink
Apply labels to reopened issues
Browse files Browse the repository at this point in the history
  • Loading branch information
WaffleLapkin committed Feb 6, 2024
1 parent b264de0 commit e2bce8b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ pub(crate) struct AutolabelLabelConfig {
#[serde(default)]
pub(crate) new_draft_pr: bool,
#[serde(default)]
pub(crate) reopened_pr: bool,
#[serde(default)]
pub(crate) reopened_draft_pr: bool,
#[serde(default)]
pub(crate) new_issue: bool,
}

Expand Down
15 changes: 14 additions & 1 deletion src/handlers/autolabel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ pub(super) async fn parse_input(
// FIXME: This will re-apply labels after a push that the user had tried to
// remove. Not much can be done about that currently; the before/after on
// synchronize may be straddling a rebase, which will break diff generation.
if event.action == IssuesAction::Opened || event.action == IssuesAction::Synchronize {
if matches!(
&event.action,
IssuesAction::Opened | IssuesAction::Reopened | IssuesAction::Synchronize
) {
let files = event
.issue
.diff(&ctx.github)
Expand Down Expand Up @@ -80,6 +83,16 @@ pub(super) async fn parse_input(
});
}

if event.issue.is_pr()
&& matches!(event.action, IssuesAction::Reopened)
&& ((cfg.reopened_pr && !event.issue.draft)
|| (cfg.reopened_draft_pr && event.issue.draft))
{
autolabels.push(Label {
name: label.to_owned(),
});
}

if !event.issue.is_pr() && cfg.new_issue && event.action == IssuesAction::Opened {
autolabels.push(Label {
name: label.to_owned(),
Expand Down

0 comments on commit e2bce8b

Please sign in to comment.