Skip to content

Only add autolabel new_pr labels on PRs #1983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/handlers/autolabel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ pub(super) async fn parse_input(
}

if let Some(files) = &files {
// This a PR.

// Add the matching labels for the modified files paths
if cfg
.trigger_files
.iter()
Expand All @@ -89,19 +92,20 @@ pub(super) async fn parse_input(
name: label.to_owned(),
});
}
}

// Treat the following situations as a "new PR":
// 1) New PRs opened as non-draft
// 2) PRs opened as draft that are marked as "ready for review" for the first time.
let is_new_non_draft_pr = event.action == IssuesAction::Opened && !event.issue.draft;
let is_first_time_ready_for_review =
event.action == IssuesAction::ReadyForReview && !state.data.new_pr_labels_applied;
if cfg.new_pr && (is_new_non_draft_pr || is_first_time_ready_for_review) {
autolabels.push(Label {
name: label.to_owned(),
});
state.data.new_pr_labels_applied = true;
// Treat the following situations as a "new PR":
// 1) New PRs opened as non-draft
// 2) PRs opened as draft that are marked as "ready for review" for the first time.
let is_new_non_draft_pr =
event.action == IssuesAction::Opened && !event.issue.draft;
let is_first_time_ready_for_review = event.action == IssuesAction::ReadyForReview
&& !state.data.new_pr_labels_applied;
if cfg.new_pr && (is_new_non_draft_pr || is_first_time_ready_for_review) {
autolabels.push(Label {
name: label.to_owned(),
});
state.data.new_pr_labels_applied = true;
}
}

if event.issue.pull_request.is_none()
Expand Down
Loading