|
15 | 15 | import argparse |
16 | 16 | import logging |
17 | 17 | import os |
| 18 | +import re |
18 | 19 | from typing import Dict, List |
19 | 20 |
|
20 | 21 | import github |
@@ -175,11 +176,18 @@ def validate_and_fetch_pull_list( |
175 | 176 | github_instance: Github, pull_list: List[str] |
176 | 177 | ) -> List[github.PullRequest.PullRequest]: |
177 | 178 | """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]+)') |
178 | 180 | repos_to_prs = {} |
179 | 181 | 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 | + |
183 | 191 | try: |
184 | 192 | pull_number = int(pull_number_str) |
185 | 193 | except TypeError: |
@@ -322,7 +330,7 @@ def parse_args(): |
322 | 330 | group.add_argument( |
323 | 331 | '-p', '--pulls', type=str, nargs='+', |
324 | 332 | 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') |
326 | 334 | group.add_argument( |
327 | 335 | '-i', '--interactive', action='store_true', |
328 | 336 | help='Prompt me to select my pull requests from a list, instead of specifying.') |
|
0 commit comments