Commit 3c1c172d authored by wychen's avatar wychen Committed by Commit bot

Extract patchset in Rietveld URLs better

Parse URL in the form of:
https://domain/<number>/#ps<patchset>

Review-Url: https://codereview.chromium.org/2215433004
parent 05c83591
......@@ -1866,6 +1866,14 @@ class _RietveldChangelistImpl(_ChangelistCodereviewBase):
def ParseIssueURL(parsed_url):
if not parsed_url.scheme or not parsed_url.scheme.startswith('http'):
return None
# Rietveld patch: https://domain/<number>/#ps<patchset>
match = re.match(r'/(\d+)/$', parsed_url.path)
match2 = re.match(r'ps(\d+)$', parsed_url.fragment)
if match and match2:
return _RietveldParsedIssueNumberArgument(
issue=int(match.group(1)),
patchset=int(match2.group(1)),
hostname=parsed_url.netloc)
# Typical url: https://domain/<issue_number>[/[other]]
match = re.match('/(\d+)(/.*)?$', parsed_url.path)
if match:
......
......@@ -145,6 +145,8 @@ class TestGitClBasic(unittest.TestCase):
123, None, 'codereview.chromium.org')
test('https://codereview.chromium.org/123/whatever',
123, None, 'codereview.chromium.org')
test('https://codereview.chromium.org/123/#ps20001',
123, 20001, 'codereview.chromium.org')
test('http://codereview.chromium.org/download/issue123_4.diff',
123, 4, 'codereview.chromium.org',
patch_url='https://codereview.chromium.org/download/issue123_4.diff')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment