Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Create links if bug number added to PR title after creation #16

Closed
edmorley opened this issue Jan 9, 2018 · 2 comments
Closed

Create links if bug number added to PR title after creation #16

edmorley opened this issue Jan 9, 2018 · 2 comments

Comments

@edmorley
Copy link

edmorley commented Jan 9, 2018

Currently only the opened event is listened to, which means the attachment isn't created if the bug number is only added after the PR is created (as has happened a few times for Treeherder PRs):

if posted.get('action') != 'opened': # only created PRs
logger.warning("Action was NOT 'opened'. It was {!r}".format(
posted.get('action')
))
return 'OK'

@peterbe
Copy link
Contributor

peterbe commented Jun 25, 2019

I suspect the reason I made it only trigger on posted.get('action') != 'opened' is because that's an action that can only happen once. If it happens on every action of a PR, we'd first need to query Bugzilla to see if there are any existing attachments, that are links to the current PR.

@peterbe
Copy link
Contributor

peterbe commented Jun 25, 2019

Actually, we already have code in place to make sure we don't add the attachment comment again.
See

for i, comment in enumerate(bug_comments):
if comment.get("is_obsolete"):
continue
if url in comment["text"]:
# exit early!
logger.info(f"Pull request URL already in comment {i+1}")
return

WIth that in mind I don't see a reason to remove the if posted.get('action') != 'opened': check.

@willkg willkg closed this as completed Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants