Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(858)

Unified Diff: git_cl.py

Issue 1363043002: Allow using issue URL for git cl patch. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index 4964350b274285e3dad3883ecd84fefeca45080e..76871fa0e90d48fcf4c6a5c6806a640dc8163072 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2873,7 +2873,16 @@ def CMDland(parser, args):
return SendUpstream(parser, args, 'land')
-@subcommand.usage('<patch url or issue id>')
+def ParseIssueNum(arg):
+ """Parses the issue number from args if present otherwise returns None."""
+ if re.match(r'\d+', arg):
+ return arg
+ if arg.startswith('http'):
+ return re.sub(r'.*/(\d+)/?', r'\1', arg)
+ return None
+
+
+@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 +2904,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 +3565,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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698