Chromium Code Reviews| Index: git_cl.py |
| diff --git a/git_cl.py b/git_cl.py |
| index 4964350b274285e3dad3883ecd84fefeca45080e..343d737755b3baf05476316c3224e510371b7e54 100755 |
| --- a/git_cl.py |
| +++ b/git_cl.py |
| @@ -2872,8 +2872,14 @@ def CMDland(parser, args): |
| ask_for_data('[Press enter to push or ctrl-C to quit]') |
| return SendUpstream(parser, args, 'land') |
| +def ParseIssueNum(arg): |
|
scottmg
2015/09/23 19:17:03
nit; two blank lines between top level functions i
dsinclair
2015/09/23 19:22:28
Done.
Didn't see comments on the other ones, didn
|
| + if re.match(r'\d+', arg): |
|
scottmg
2015/09/23 19:17:03
maybe
or args.endswith('.diff')
would be a saf
dsinclair
2015/09/23 19:22:28
It's not as easy to share in that case as the git
scottmg
2015/09/23 19:35:45
Oh, right. OK, lgtm then.
|
| + return arg |
| + if arg.startswith('http'): |
| + return re.sub(r'.*/(\d+)/?', r'\1', arg) |
| + return None |
| -@subcommand.usage('<patch url or issue id>') |
| +@subcommand.usage('<patch url or issue id or issue url>') |
| def CMDpatch(parser, args): |
| """Patches in a code review.""" |
| parser.add_option('-b', dest='newbranch', |
| @@ -2895,7 +2901,13 @@ def CMDpatch(parser, args): |
| if len(args) != 1: |
| parser.print_help() |
| return 1 |
| - issue_arg = args[0] |
| + |
| + issue_arg = ParseIssueNum(args[0]) |
| + # The patch URL works because ParseIssueNum won't do any substitution |
| + # as the re.sub pattern fails to match and just returns it. |
| + if issue_arg == None: |
| + parser.print_help() |
| + return 1 |
| # We don't want uncommitted changes mixed up with the patch. |
| if git_common.is_dirty_git_tree('patch'): |
| @@ -3550,11 +3562,8 @@ def CMDcheckout(parser, args): |
| parser.print_help() |
| return 1 |
| - if re.match(r'\d+', args[0]): |
| - target_issue = args[0] |
| - elif args[0].startswith('http'): |
| - target_issue = re.sub(r'.*/(\d+)/?', r'\1', args[0]) |
| - else: |
| + target_issue = ParseIssueNum(args[0]) |
| + if target_issue == None: |
| parser.print_help() |
| return 1 |