8000 Remove autolink to bpo ticket. · python/bedevere@78b15e2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 78b15e2

Browse files
committed
Remove autolink to bpo ticket.
We get autolinking for free now. Closes python/core-workflow#361
1 parent 3bb3786 commit 78b15e2

File tree

1 file changed

+0
-65
lines changed

1 file changed

+0
-65
lines changed

bedevere/bpo.py

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -81,27 +81,6 @@ async def removed_label(event, gh, *args, session, **kwargs):
8181
await set_status(event, gh, session=session)
8282

8383

84-
@router.register("issue_comment", action="edited")
85-
@router.register("issue_comment", action="created")
86-
@router.register("commit_comment", action="edited")
87-
@router.register("commit_comment", action="created")
88-
@router.register("pull_request", action="edited")
89-
@router.register("pull_request", action="opened")
90-
async def hyperlink_bpo_text(event, gh, *args, **kwargs):
91-
if "pull_request" in event.data:
92-
event_name = "pull_request"
93-
body_location = "issue_url"
94-
else:
95-
event_name = "comment"
96-
body_location = "url"
97-
if "body" in event.data[event_name] and body_location in event.data[event_name]:
98-
body = event.data[event_name]["body"] or ""
99-
new_body = create_hyperlink_in_comment_body(body)
100-
if new_body != body:
101-
body_data = {"body": new_body}
102-
await gh.patch(event.data[event_name][body_location], data=body_data)
103-
104-
10584
def create_success_status(issue_number):
10685
"""Create a success status for when an issue number was found in the title."""
10786
url = f"https://bugs.python.org/issue{issue_number}"
@@ -128,50 +107,6 @@ def create_failure_status_no_issue():
128107
target_url=url)
129108

130109

131-
def check_hyperlink(match):
132-
"""The span checking of regex matches takes care of cases like bpo-123 [bpo-123]…"""
133-
issue = match.group("issue")
134-
markdown_link_re = re.compile(r"""
135-
\[[^\]]*bpo-(?P<issue>{issue})[^\]]*\]
136-
\(\s*https://bugs.python.org/issue{issue}\s*\)""".format(issue=issue),
137-
re.VERBOSE)
138-
html_link_re = re.compile(r""" <a
139-
\s*href\s*=\s*[",']\s*
140-
https://bugs.python.org/issue{issue}
141-
\s*[",']\s*>
142-
\s*bpo-(?P<issue>{issue})\s*
143-
</a>""".format(issue=issue),
144-
re.VERBOSE)
145-
for markdown_match in markdown_link_re.finditer(match.string):
146-
if markdown_match.span("issue") == match.span("issue"):
147-
return markdown_match.end()
148-
for html_match in html_link_re.finditer(match.string):
149-
if html_match.span("issue& DBD9 quot;) == match.span("issue"):
150-
return html_match.end()
151-
152-
return False
153-
154-
155-
def create_hyperlink_in_comment_body(body):
156-
"""Uses infinite loop for updating the string being searched dynamically."""
157-
new_body = ""
158-
leftover_body = body
159-
while True:
160-
match = ISSUE_RE.search(leftover_body)
161-
if match is None:
162-
break
163-
presence = check_hyperlink(match)
164-
if presence is False:
165-
new_body = new_body + leftover_body[:match.start()]
166-
leftover_body = leftover_body[match.end():]
167-
new_body = new_body + match.expand(r"[bpo-\g<issue>](https://bugs.python.org/issue\g<issue>)")
168-
else:
169-
new_body = new_body + leftover_body[:presence]
170-
leftover_body = leftover_body[presence:]
171-
new_body = new_body + leftover_body
172-
return new_body
173-
174-
175110
async def _validate_issue_number(issue_number, session):
176111
"""Make sure the issue number exists on bugs.python.org."""
177112
url = f"https://bugs.python.org/issue{issue_number}"

0 commit comments

Comments
 (0)
0