Skip to content

Commit

Permalink
[git-webkit] Link radars in PR descriptions
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=263723
rdar://117535561

Reviewed by Dewei Zhu.

Use https://rdar.apple.com to link to Radars in pull-request descriptions.

* Tools/CISupport/ews-build/steps.py:
(UpdatePullRequest.escape_html): Convert references to rdar:// with https://rdar.apple.com.
* Tools/CISupport/ews-build/steps_unittest.py:
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/pull_request.py:
(PullRequest.escape_html): Convert references to rdar:// with https://rdar.apple.com.
(PullRequest.unescape_html): Make linkage escapes more generic to capture converted radar links.
* Tools/Scripts/libraries/webkitscmpy/webkitscmpy/test/pull_request_unittest.py:
(TestPullRequest.test_create_body_single_linked): Added.

Canonical link: https://commits.webkit.org/269986@main
  • Loading branch information
JonWBedard committed Oct 31, 2023
1 parent 4235d27 commit e0b3ca0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Tools/CISupport/ews-build/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6439,7 +6439,8 @@ class UpdatePullRequest(shell.ShellCommandNewStyle, GitHubMixin, AddToLogMixin):
@classmethod
def escape_html(cls, message):
message = ''.join(cls.ESCAPE_TABLE.get(c, c) for c in message)
return re.sub(r'(https?://[^\s<>,:;]+?)(?=[\s<>,:;]|(&gt))', r'<a href="\1">\1</a>', message)
message = re.sub(r'(https?://[^\s<>,:;]+?)(?=[\s<>,:;]|(&gt))', r'<a href="\1">\1</a>', message)
return re.sub(r'rdar://([^\s<>,:;]+?)(?=[\s<>,:;]|(&gt))', r'<a href="https://rdar.apple.com/\1">rdar://\1</a>', message)

def __init__(self, **kwargs):
super().__init__(logEnviron=False, timeout=300, **kwargs)
Expand Down
10 changes: 5 additions & 5 deletions Tools/CISupport/ews-build/steps_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8261,7 +8261,7 @@ def update_pr(x, pr_number, title, description, base=None, head=None, repository
<pre>
[Merge-Queue] Add http credential helper
<a href="https://bugs.webkit.org/show_bug.cgi?id=238553">https://bugs.webkit.org/show_bug.cgi?id=238553</a>
&lt;rdar://problem/91044821&gt;
&lt;<a href="https://rdar.apple.com/problem/91044821">rdar://problem/91044821</a>&gt;
Reviewed by NOBODY (OOPS!).
Expand Down Expand Up @@ -8427,11 +8427,11 @@ def update_pr(x, pr_number, title, description, base=None, head=None, repository
description,
'''#### 9140b95e718e7342366bbcdc29cb1ba0f9328422
<pre>
Cherry-pick 252432.1026@safari-7614-branch (2a8469e53b2f). rdar://107367418
Cherry-pick 252432.1026@safari-7614-branch (2a8469e53b2f). <a href="https://rdar.apple.com/107367418">rdar://107367418</a>
Remove inheritance of designMode attribute
<a href="https://bugs.webkit.org/show_bug.cgi?id=248615">https://bugs.webkit.org/show_bug.cgi?id=248615</a>
rdar://102868995
<a href="https://rdar.apple.com/102868995">rdar://102868995</a>
Reviewed by Wenson Hsieh and Jonathan Bedard.
Expand All @@ -8457,11 +8457,11 @@ def update_pr(x, pr_number, title, description, base=None, head=None, repository
----------------------------------------------------------------------
#### 6ec5319be307db36a27ea61d208cf68ce84abd67
<pre>
Cherry-pick 252432.1024@safari-7614-branch (2ea437d75522). rdar://107367090
Cherry-pick 252432.1024@safari-7614-branch (2ea437d75522). <a href="https://rdar.apple.com/107367090">rdar://107367090</a>
Use-after-free in ContactsManager::select
<a href="https://bugs.webkit.org/show_bug.cgi?id=250351">https://bugs.webkit.org/show_bug.cgi?id=250351</a>
rdar://101241436
<a href="https://rdar.apple.com/101241436">rdar://101241436</a>
Reviewed by Wenson Hsieh and Jonathan Bedard.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ def __repr__(self):
@classmethod
def escape_html(cls, message):
message = ''.join(cls.ESCAPE_TABLE.get(c, c) for c in message)
return re.sub(r'(https?://[^\s<>,:;]+?)(?=[\s<>,:;]|(&gt))', r'<a href="\1">\1</a>', message)
message = re.sub(r'(https?://[^\s<>,:;]+?)(?=[\s<>,:;]|(&gt))', r'<a href="\1">\1</a>', message)
return re.sub(r'rdar://([^\s<>,:;]+?)(?=[\s<>,:;]|(&gt))', r'<a href="https://rdar.apple.com/\1">rdar://\1</a>', message)

@classmethod
def unescape_html(cls, message):
message = re.sub(r'<a href=".+">(https?://[^\s<>,:;]+)</a>', r'\1', message)
message = re.sub(r'<a href="https?://.+">([^\s<>,:;/]+://[^\s<>,:;]+)</a>', r'\1', message)
for c, escaped in cls.ESCAPE_TABLE.items():
message = message.replace(escaped, c)
return message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ def test_create_body_single_linked(self):
self.assertEqual(
PullRequest.create_body(None, [Commit(
hash='11aa76f9fc380e9fe06157154f32b304e8dc4749',
message='[scoping] Bug to fix\n\nReviewed by Tim Contributor.\n',
message='[scoping] Bug to fix\nhttps://bugs.webkit.org/1234\nrdar://1234\n\nReviewed by Tim Contributor.\n',
)]), '''#### 11aa76f9fc380e9fe06157154f32b304e8dc4749
<pre>
[scoping] Bug to fix
<a href="https://bugs.webkit.org/1234">https://bugs.webkit.org/1234</a>
<a href="https://rdar.apple.com/1234">rdar://1234</a>
Reviewed by Tim Contributor.
</pre>''',
Expand Down Expand Up @@ -75,7 +77,7 @@ def test_parse_body_single(self):
self.assertEqual(commits[0].hash, '11aa76f9fc380e9fe06157154f32b304e8dc4749')
self.assertEqual(commits[0].message, '[scoping] Bug to fix\n\nReviewed by Tim Contributor.')

def test_parse_body_single(self):
def test_parse_body_single_ews(self):
body, commits = PullRequest.parse_body('''#### 11aa76f9fc380e9fe06157154f32b304e8dc4749
```
[scoping] Bug to fix
Expand Down Expand Up @@ -120,7 +122,7 @@ def test_create_body_multiple_linked(self):
#### ccc39e76f938a1685e388991fc3127a85d0be0f0
<pre>
[scoping] Bug to fix (Part 1)
&lt;rdar:///1234&gt;
&lt;<a href="https://rdar.apple.com//1234">rdar:///1234</a>&gt;
Reviewed by Tim Contributor.
</pre>''',
Expand Down Expand Up @@ -274,6 +276,23 @@ def test_parse_html_body_single(self):
self.assertEqual(commits[0].hash, '11aa76f9fc380e9fe06157154f32b304e8dc4749')
self.assertEqual(commits[0].message, '[scoping] Bug to fix\n\nReviewed by Tim Contributor.')

def test_parse_html_body_single_links(self):
body, commits = PullRequest.parse_body('''Comment body
----------------------------------------------------------------------
#### 11aa76f9fc380e9fe06157154f32b304e8dc4749
<pre>
[scoping] Bug to fix
<a href="https://bugs.webkit.org/1234">https://bugs.webkit.org/1234</a>
<a href="https://rdar.apple.com/1234">rdar://1234</a>
Reviewed by Tim Contributor.
</pre>''')
self.assertEqual(body, 'Comment body')
self.assertEqual(len(commits), 1)
self.assertEqual(commits[0].hash, '11aa76f9fc380e9fe06157154f32b304e8dc4749')
self.assertEqual(commits[0].message, '[scoping] Bug to fix\nhttps://bugs.webkit.org/1234\nrdar://1234\n\nReviewed by Tim Contributor.')

def test_parse_html_body_single_ews(self):
body, commits = PullRequest.parse_body('''Comment body
Expand Down Expand Up @@ -864,7 +883,6 @@ def test_github_branch_number(self):
)

def test_github_number_reentrance(self):
self.maxDiff = None
with OutputCapture(level=logging.INFO) as captured, mocks.remote.GitHub(
projects=bmocks.PROJECTS) as remote, bmocks.Bugzilla(
self.BUGZILLA.split('://')[-1],
Expand Down Expand Up @@ -1174,7 +1192,6 @@ def test_github_branch_redaction_exemption(self):
self.assertEqual(gh_issue.project, 'WebKit')
self.assertEqual(gh_issue.component, 'Scrolling')

self.maxDiff = None
self.assertEqual(
captured.stdout.getvalue(),
"A commit you are uploading references https://bugs.example.com/show_bug.cgi?id=1\n"
Expand Down

0 comments on commit e0b3ca0

Please sign in to comment.