|
4 | 4 |
|
5 | 5 |
|
6 | 6 | router = routing.Router()
|
7 |
| -re1='(<!--.*?-->)' # HTML Comment 1 |
8 |
| -re2='.*?' # Non-greedy match on filler |
9 |
| -re3='((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))' # HTTP URL 1 |
10 |
| -re4='.*?' # Non-greedy match on filler |
11 |
| -re5='(<!--.*?-->)' # HTML Comment 2 |
12 |
| -BPO_URL_RE = re.compile(re1+re2+re3+re4+re5,re.IGNORECASE|re.DOTALL) |
13 |
| -BPO_MSG = """{0} |
14 |
| -<!-- issue number --> |
15 |
| -{1} |
16 |
| -<!-- /issue number -->""" |
| 7 | +TAG_NAME = "issue-number" |
| 8 | +CLOSING_TAG = f"<!-- /{TAG_NAME} -->" |
| 9 | + |
17 | 10 | ISSUE_RE = re.compile(r"bpo-(?P<issue>\d+)")
|
18 | 11 | STATUS_TEMPLATE = {"context": "bedevere/issue-number"}
|
19 | 12 | FAILURE_STATUS = STATUS_TEMPLATE.copy()
|
@@ -53,11 +46,14 @@ async def set_status(event, gh, *args, **kwargs):
|
53 | 46 | else:
|
54 | 47 | if "body" in event.data["pull_request"]:
|
55 | 48 | body = event.data["pull_request"]["body"]
|
56 |
| - bpo_url_found = BPO_URL_RE.search(body) |
57 |
| - if not bpo_url_found: |
58 |
| - issue_number = issue_number_found.group(1) |
59 |
| - bpo_url = f"https://bugs.python.org/issue{issue_number}" |
60 |
| - data = {"body": BPO_MSG.format(body, bpo_url)} |
| 49 | + if CLOSING_TAG not in body: |
| 50 | + issue_number = issue_number_found.group("issue") |
| 51 | + BPO_MSG = f"""{body}\n |
| 52 | +<!-- {TAG_NAME}: bpo-{issue_number} --> |
| 53 | +https://bugs.python.org/issue{issue_number} |
| 54 | +{CLOSING_TAG} |
| 55 | +""" |
| 56 | + data = {"body": BPO_MSG} |
61 | 57 | await _patch_body(event, gh, data)
|
62 | 58 | status = create_success_status(issue_number_found)
|
63 | 59 | await _post_status(event, gh, status)
|
|
0 commit comments