Skip to content

Do not apply labels in autolabel when opening a draft PR #1968

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 10, 2025

Conversation

Kobzol
Copy link
Contributor

@Kobzol Kobzol commented May 6, 2025

After #1963, it doesn't make sense to apply S-waiting-on-review to PRs opened as a draft. According to https://github.com/search?type=code&q=org%3Arust-lang+%22new_pr+%3D+true%22, this option is only ever used for adding S-waiting-on-review in the rust-lang org, so I don't think that we need to complicate the settings by adding some "new_nondraft_pr" setting or something like that.

@Kobzol Kobzol requested a review from Urgau May 6, 2025 07:11
@Kobzol Kobzol marked this pull request as draft May 6, 2025 07:14
@Kobzol
Copy link
Contributor Author

Kobzol commented May 6, 2025

Actually, this won't work on its own, because when a draft PR is opened, it won't get S-waiting-on-review, and once it's converted from draft, it will get assigned someone, but it won't have that label.

Maybe we should modify autolabel to treat both "opened as non draft" and "converted from draft" as triggering new_pr = true?

@apiraino
Copy link
Contributor

apiraino commented May 6, 2025

I'm thinking if it makes sense applying any kind of post-processing to draft PRs. Is there anything the triagebot needs to do on drafts?

Would it be too radical to set a global is_draft() gate on all handlers and just skip everything?

@Kobzol
Copy link
Contributor Author

Kobzol commented May 6, 2025

We might go in that direction, yeah. In theory we could just ignore draft PRs completely, and the first time they are converted from draft to open, we could treat it in triagebot as them opening at that very moment. But that would probably require some larger changes.

@Urgau
Copy link
Member

Urgau commented May 6, 2025

Maybe we should modify autolabel to treat both "opened as non draft" and "converted from draft" as triggering new_pr = true?

Make sense to me.

@Kobzol Kobzol force-pushed the autolabel-draft branch from f46e21c to f9aa4a8 Compare May 7, 2025 08:06
@Kobzol Kobzol marked this pull request as ready for review May 7, 2025 08:06
@Kobzol
Copy link
Contributor Author

Kobzol commented May 7, 2025

Ok, I changed the logic, let me know what do you think.

@Kobzol Kobzol force-pushed the autolabel-draft branch 2 times, most recently from 8394cc9 to ed0084f Compare May 7, 2025 12:20
@Kobzol Kobzol force-pushed the autolabel-draft branch from ed0084f to a5c8675 Compare May 10, 2025 09:35
@Kobzol Kobzol force-pushed the autolabel-draft branch from a5c8675 to 2eb3d58 Compare May 10, 2025 09:37
@Urgau Urgau added this pull request to the merge queue May 10, 2025
Merged via the queue into rust-lang:master with commit 2579367 May 10, 2025
3 checks passed
@Kobzol Kobzol deleted the autolabel-draft branch May 10, 2025 10:25
@Kobzol
Copy link
Contributor Author

Kobzol commented May 10, 2025

Seems to work fine: rust-lang/rust#140889.

Comment on lines +94 to 105
// 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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have stayed in the condition above, as we are putting new_pr labels on issues instead of only PRs.

I knew this was iffy, but couldn't prove it, thks @jieyouxu.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #1983 to fix it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants