mirror of
https://github.com/openSUSE/osc.git
synced 2025-12-27 03:04:16 +01:00
Merge pull request #2018 from dmach/fix-PullRequest.split_id-trailing-whitespaces
Make PullReqest.parse_id() more permissive by accepting trailing whitespaces
This commit is contained in:
@@ -29,9 +29,9 @@ class PullRequest(GiteaModel):
|
||||
"""
|
||||
Split <owner>/<repo>#<number> or <owner>/<repo>!<number> into individual components and return them in a tuple.
|
||||
"""
|
||||
match = re.match(r"^([^/]+)/([^/]+)[#!]([0-9]+)$", pr_id)
|
||||
match = re.match(r"^([^/]+)/([^/]+)[#!]([0-9]+)\s*$", pr_id)
|
||||
if not match:
|
||||
match = re.match(r"^([^/]+)/([^/]+)/pulls/([0-9]+)$", pr_id)
|
||||
match = re.match(r"^([^/]+)/([^/]+)/pulls/([0-9]+)\s*$", pr_id)
|
||||
|
||||
if not match:
|
||||
raise ValueError(f"Invalid pull request id: {pr_id}")
|
||||
|
||||
@@ -167,7 +167,7 @@ class TestGiteaApiPullRequestUrlParsing(unittest.TestCase):
|
||||
class TestGiteaApiPullRequestReferences(unittest.TestCase):
|
||||
PR_BODY = """
|
||||
PR: foo/bar!1
|
||||
PR: foo/bar#2
|
||||
PR: foo/bar#2\r
|
||||
text
|
||||
PR: bar/baz#3
|
||||
text
|
||||
@@ -190,7 +190,7 @@ text
|
||||
actual = PullRequest.add_pr_references(self.PR_BODY, [('xxx', 'xxx', 4), ('yyy', 'yyy', 5)])
|
||||
expected = """
|
||||
PR: foo/bar!1
|
||||
PR: foo/bar#2
|
||||
PR: foo/bar#2\r
|
||||
text
|
||||
PR: bar/baz#3
|
||||
PR: xxx/xxx!4
|
||||
@@ -207,7 +207,7 @@ text
|
||||
actual = PullRequest.add_pr_references(self.PR_BODY + "\nPR: a/b#123", [('xxx', 'xxx', 4), ('yyy', 'yyy', 5)])
|
||||
expected = """
|
||||
PR: foo/bar!1
|
||||
PR: foo/bar#2
|
||||
PR: foo/bar#2\r
|
||||
text
|
||||
PR: bar/baz#3
|
||||
text
|
||||
|
||||
Reference in New Issue
Block a user