Skip to content

Commit

Permalink
backport-resolve-issue: extract PR number more carefully
Browse files Browse the repository at this point in the history
This addresses cases where the previous regex '\\d++' was promiscuously
matching strings of digits that were not GitHub PR IDs.

Signed-off-by: Nathan Cutler <[email protected]>
  • Loading branch information
smithfarm committed Feb 12, 2020
1 parent 5959ac2 commit 9ea48e8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/script/backport-resolve-issue
Original file line number Diff line number Diff line change
Expand Up @@ -510,12 +510,13 @@ Ceph version: base {}, target {}'''.format(self.github_url, pr_title_trunc,
def populate_github_url(self):
global github_endpoint
# GitHub PR ID from merge commit string
p = re.compile('\\d+')
p = re.compile('(pull request|PR) #(\\d+)')
try:
self.github_pr_id = p.search(self.merge_commit_description).group()
self.github_pr_id = p.search(self.merge_commit_description).group(2)
except AttributeError:
assert False, \
"Failed to extract GitHub PR ID from merge commit string ->{}<-".format(self.merge_commit_string)
logging.debug("Merge commit string: {}".format(self.merge_commit_string))
logging.debug("GitHub PR ID from merge commit string: {}".format(self.github_pr_id))
self.github_url = "{}/pull/{}".format(github_endpoint, self.github_pr_id)

Expand Down

0 comments on commit 9ea48e8

Please sign in to comment.