Skip to content

Commit 09a79df

Browse files
committed
Only add autolabel new_pr labels on PRs
1 parent 2579367 commit 09a79df

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/handlers/autolabel.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ pub(super) async fn parse_input(
8080
}
8181

8282
if let Some(files) = &files {
83+
// This a PR.
84+
85+
// Add the matching labels for the modified files paths
8386
if cfg
8487
.trigger_files
8588
.iter()
@@ -89,19 +92,20 @@ pub(super) async fn parse_input(
8992
name: label.to_owned(),
9093
});
9194
}
92-
}
9395

94-
// Treat the following situations as a "new PR":
95-
// 1) New PRs opened as non-draft
96-
// 2) PRs opened as draft that are marked as "ready for review" for the first time.
97-
let is_new_non_draft_pr = event.action == IssuesAction::Opened && !event.issue.draft;
98-
let is_first_time_ready_for_review =
99-
event.action == IssuesAction::ReadyForReview && !state.data.new_pr_labels_applied;
100-
if cfg.new_pr && (is_new_non_draft_pr || is_first_time_ready_for_review) {
101-
autolabels.push(Label {
102-
name: label.to_owned(),
103-
});
104-
state.data.new_pr_labels_applied = true;
96+
// Treat the following situations as a "new PR":
97+
// 1) New PRs opened as non-draft
98+
// 2) PRs opened as draft that are marked as "ready for review" for the first time.
99+
let is_new_non_draft_pr =
100+
event.action == IssuesAction::Opened && !event.issue.draft;
101+
let is_first_time_ready_for_review = event.action == IssuesAction::ReadyForReview
102+
&& !state.data.new_pr_labels_applied;
103+
if cfg.new_pr && (is_new_non_draft_pr || is_first_time_ready_for_review) {
104+
autolabels.push(Label {
105+
name: label.to_owned(),
106+
});
107+
state.data.new_pr_labels_applied = true;
108+
}
105109
}
106110

107111
if event.issue.pull_request.is_none()

0 commit comments

Comments
 (0)