Skip to content

Commit ccbeb66

Browse files
committed
Handle closing and reopening PRs for the [autolabel] new_pr labels
1 parent 0c50534 commit ccbeb66

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/handlers/autolabel.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ pub(super) async fn parse_input(
2929
if matches!(
3030
event.action,
3131
IssuesAction::Opened
32+
| IssuesAction::Closed
33+
| IssuesAction::Reopened
3234
| IssuesAction::Synchronize
3335
| IssuesAction::ReadyForReview
3436
| IssuesAction::ConvertedToDraft
@@ -84,19 +86,25 @@ pub(super) async fn parse_input(
8486
}
8587

8688
// Treat the following situations as a "new PR":
87-
// 1) New PRs opened as non-draft
88-
// 2) PRs opened as draft that are marked as "ready for review".
89-
let is_new_non_draft_pr =
90-
event.action == IssuesAction::Opened && !event.issue.draft;
89+
// 1) PRs that were (re)opened and are not draft
90+
// 2) PRs that have been converted from a draft to being "ready for review"
91+
let is_opened_non_draft =
92+
matches!(event.action, IssuesAction::Opened | IssuesAction::Reopened)
93+
&& !event.issue.draft;
9194
let is_ready_for_review = event.action == IssuesAction::ReadyForReview;
92-
if cfg.new_pr && (is_new_non_draft_pr || is_ready_for_review) {
95+
if cfg.new_pr && (is_opened_non_draft || is_ready_for_review) {
9396
autolabels.push(Label {
9497
name: label.to_owned(),
9598
});
9699
}
97100

98-
// If a PR is converted to draft remove all the "new PR" labels
99-
if cfg.new_pr && event.action == IssuesAction::ConvertedToDraft {
101+
// If a PR is converted to draft or closed, remove all the "new PR" labels
102+
if cfg.new_pr
103+
&& matches!(
104+
event.action,
105+
IssuesAction::ConvertedToDraft | IssuesAction::Closed
106+
)
107+
{
100108
to_remove.push(Label {
101109
name: label.to_owned(),
102110
});

0 commit comments

Comments
 (0)