-
Notifications
You must be signed in to change notification settings - Fork 94
Normalize labels before addition or removal #2128
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
I feel like it's unreasonable for GitHub to allow emoji in label names but here we are.
Unless I'm mistaken, your function would allow the same prefix to be match to multiple emoji. So "label 🤷", "label 👍" and "label 💯" would all be matched by "label", right? I don't think we should allow any of those to match "label", I feel like we should require perfect match in those cases. I didn't look too closely at the code but I saw that there wasn't any caching done, we'll need to add some, at minimum per webhook request, maybe in |
Can't argue with that, lol.
This is a great point, so I have added an error for this case:
I didn't implement any caching, however this implementation will send far fewer requests to GitHub – previously a |
Thanks for the PR. Let's try it. |
Let's do some quick sanity checks. @rustbot label A-test |
@rustbot label A-test-emoji |
Unknown labels: A-test-emoji |
@rustbot label "A-test-emoji 😄" |
Unknown labels: A-test-emoji 😄 |
@rustbot label "A-test-emoji 😄" |
@rustbot label "-A-test-emoji 😄" "-A-test" |
@rustbot label A-test-emoji-2 |
Hum, this doesn't work 100% as I would have expected. GitHub allows both Unicode emoji characters and the Markdown named ones ( It works fine for the Unicode emoji, but not for the second one. Fortunately the crates.io repository uses the Unicode ones, so it's fine but still a bit unexpected. |
I think this may have broken standard ascii labels in some way too; libc's autolabel has started claiming everything is unknown rust-lang/libc#4607 (comment) rust-lang/libc#4608 (comment) |
Oh, that's definitely an oversight that should be addressed.
even worse! Okay, I will revisit this with some new test cases based on these issues. Probably worth rolling this back if you haven't already. Apologies for the inconvenience. |
That's probably why the original implementation made the GET request for each label... |
Revert on going at #2133, apologies for the inconvenience. |
Revert "Merge pull request #2128 from kailan/normalize-labels"
The crates.io repository has some cute emoji in the label names, but this interferes with usage of label-related triagebot commands. Example:
It seems unreasonable to expect users to exactly match the label names in these cases, and it would be a shame to remove the emoji from the label names, so I feel that it makes sense to make triagebot a bit more lax when it comes to finding labels.
This PR adds a
normalize_and_match_labels
function, which takes a set of "requested" label names and attempts to match them to the labels available in the repository. This will always return an exact match, if it exists, but otherwise will strip emoji, ignore casing, and ignore leading and trailing whitespace in an attempt to find the relevant label.This function is used in the lower level
add_labels
andremove_label
functions so that it can apply across any triagebot commands that handle labels. This means that the existing configuration for autolabelling in crates.io will start working:This PR is somewhat related to #1372.