-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Propagate labels from the issue to the PR #2357
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
✅ Deploy Preview for pytorch-tutorials-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
run: | | ||
pip install requests | ||
pip install PyGithub | ||
- name: Run Python script |
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.
It's the same the previous step, remove?
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.
resolved
pip install requests | ||
pip install PyGithub | ||
- name: Set up env var | ||
run: echo "PR_NUMBER=$((${{ github.event.pull_request.number }}))" >> $GITHUB_ENV |
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.
Instead of a separate step for "Set up env var", you can pass the PR number like this:
https://github.com/pytorch/pytorch/blob/main/.github/workflows/check-labels.yml#L52
|
||
# get issue number from the PR body | ||
if re.search(r'#\d{1,5}', pull_request_body): | ||
issue_number = int(re.findall(r'#(\d{1,5})', pull_request_body)[0]) |
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.
This is too brittle.
What if there is a text like "This is a follow-up of for my PR #12345", then repo.get_issue
will fail.
Also I'm not sure pull_request_body
returns "#12345" and not "https://github.com/pytorch/tutorials/issue/12345"
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.
As discussed separately, for this purpose, this solution will suffice.
issue_label_names = [label.name for label in issue_labels] | ||
labels_to_add = [label for label in issue_label_names if label not in pull_request_labels] | ||
if labels_to_add: | ||
pull_request.set_labels(*labels_to_add) |
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.
Name set_labels
implies it will delete existing labels, would't it? Can you please add a ref to the doc showing that it would not remove existing labels?
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.
Probably need to use add_to_labels
instead.
Co-authored-by: Nikita Shulga <nshulga@meta.com>
Co-authored-by: Nikita Shulga <nshulga@meta.com>
Co-authored-by: Nikita Shulga <nshulga@meta.com>
Add a GH action that propagates labels from the issue to PR. The issue must be tagged with the docathon label.