Skip to content

Commit 49626cb

Browse files
authored
Allow validate_and_fetch_pull_list to take URLs. (#16)
Signed-off-by: Chris Lalancette <clalancette@gmail.com>
1 parent 040fb4e commit 49626cb

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

ros_github_scripts/ci_for_pr.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import argparse
1616
import logging
1717
import os
18+
import re
1819
from typing import Dict, List
1920

2021
import github
@@ -175,11 +176,18 @@ def validate_and_fetch_pull_list(
175176
github_instance: Github, pull_list: List[str]
176177
) -> List[github.PullRequest.PullRequest]:
177178
"""Fetch GitHub pull requests given the "org/repo#N" string input specifier format."""
179+
github_url_re = re.compile(r'https://github.com/(.*)/(.*)/pull/([0-9]+)')
178180
repos_to_prs = {}
179181
for pull in pull_list:
180-
if pull.count('#') != 1:
181-
panic("Pull request descriptor doesn't match org/repo#number format: {}".format(pull))
182-
repo, pull_number_str = pull.split('#')
182+
url_match = re.match(github_url_re, pull)
183+
if url_match is not None:
184+
repo = '/'.join([url_match[1], url_match[2]])
185+
pull_number_str = url_match[3]
186+
else:
187+
if pull.count('#') != 1:
188+
panic("Pull request descriptor doesn't match org/repo#number format: {}".format(pull))
189+
repo, pull_number_str = pull.split('#')
190+
183191
try:
184192
pull_number = int(pull_number_str)
185193
except TypeError:
@@ -322,7 +330,7 @@ def parse_args():
322330
group.add_argument(
323331
'-p', '--pulls', type=str, nargs='+',
324332
help='Space-separated list of pull requests to process, in format ORG/REPO#PULLNUMBER '
325-
'(e.g. ros2/rclpy#353)')
333+
'(e.g. ros2/rclpy#353) or https://github.com/ORG/REPO/pull/PULLNUMBER')
326334
group.add_argument(
327335
'-i', '--interactive', action='store_true',
328336
help='Prompt me to select my pull requests from a list, instead of specifying.')

0 commit comments

Comments
 (0)