-
Notifications
You must be signed in to change notification settings - Fork 97
Apply labels from left to right in relabel #2189
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
Conversation
| let mut add = BTreeSet::new(); | ||
| let mut remove = BTreeSet::new(); | ||
|
|
||
| for delta in deltas { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note to myself: this implementation means that doing +foo -foo -foo will actually remove foo from the issue. This is probably useful for something like alias -foo, where alias does +foo -foo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, and it also means that +foo +foo -foo does nothing (+foo +foo -> +foo and +foo -foo cancels each other out).
| let Some(issue) = event.issue() else { | ||
| anyhow::bail!("event is not an issue"); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Urgau why did you introduce this block?
I don't know for other people but I need to be able to edit labels on both pull requests and issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PRs are also issues, so this should work fine. The code before did an unwrap on event.issue() anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah wait maybe I am misunderstanding: Issue here is meant as both a "ticket" and a pull request so Event::Issue covers both.
But I still don't understand why adding this check: what other event are you preventing to happen?
The error message at least is confusing, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you introduce this block?
Because the code below was asserting the presence of it. It's better return a message than panic and block all the other handlers.
We should indeed probably change the message to be explicitly about PRs since it's now a user message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should indeed probably change the message to be explicitly about PRs since it's now a user message.
I'm working on #2172 I will change that as well
As we discussed in #2172 and in #t-compiler/contrib-private > RFC: triagebot parsing command aliases the way labels are applied in relabel is weird when the same label is used multiple times.
This PR makes the behavior more user friendly by pre-computing a "final state" where all the label deltas are applied from left to right, meaning that
+label -label/-label +labelwould cancel each other instead of using the issue state.Best reviewed commit by commit.