probot / reminders

set reminders on Issues and Pull Requests
https://github.com/apps/reminders
ISC License
162 stars 24 forks source link

label management thoughts #6

Closed jbjonesjr closed 6 years ago

jbjonesjr commented 7 years ago

https://github.com/probot/reminders/blob/bf6e72f55b8a85b95e10daa52ae42ff9c2fb50c6/lib/reminders.js#L22-L26

First, slight optimization:

You should be able to only perform the issue.edit if the labels have changed, aka, something like:

(labels.length != issue.labels.length) await context.github.issues.edit(context.issue({labels})); (or whatever the proper modern javascript syntax is for that)

Next, since adding a label to an issue requires you to determine if it already exists for the issue, use iterators/find, conditionals, and then and updating the issue if necessary, it would be awesome if this could be abstracted from the user. Whether a little node-github helper library or node-github itself, providing some abstracted, optimized methods for tasks like this would help all. Of course, it would be great if the GitHub API supported this, but we could provide some JS help in the meantime. Thoughts?

bkeepers commented 7 years ago

You should be able to only perform the issue.edit if the labels have changed, aka, something like:

Ahh, good catch.

Next, since adding a label to an issue requires you to determine if it already exists for the issue, use iterators/find, conditionals, and then and updating the issue if necessary, it would be awesome if this could be abstracted from the user.

I think you can use this endpoint (github.issues.addLabels on node-github) to add labels to an issue, and it doesn't care if the label is already on the issue.

stale[bot] commented 6 years ago

Is this still relevant? If so, please comment with any updates or addition details.