From a3683bbbeed3e23822c2c8696d1dbbfd22ccaaeb Mon Sep 17 00:00:00 2001 From: "jochen@chromium.org" Date: Tue, 11 May 2010 15:35:12 +0000 Subject: [PATCH] Enable CheckRietveldTryJobExecution for git-cl. Review URL: http://codereview.chromium.org/1993008 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@46923 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl_hooks.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/git_cl_hooks.py b/git_cl_hooks.py index f884e6895d..7d74be51a3 100644 --- a/git_cl_hooks.py +++ b/git_cl_hooks.py @@ -20,6 +20,13 @@ def Backquote(cmd, cwd=None): cwd=cwd, stdout=subprocess.PIPE).communicate()[0].strip() +def BackquoteAsInteger(cmd, cwd=None): + """Like Backquote, but returns either an int or None.""" + try: + return int(Backquote(cmd, cwd)) + except ValueError: + return None + class ChangeOptions: def __init__(self, commit=None, upstream_branch=None): @@ -41,12 +48,12 @@ class ChangeOptions: raise Exception("Could not parse log message: %s" % log) name = m.group(1) files = scm.GIT.CaptureStatus([root], upstream_branch) - issue = Backquote(['git', 'cl', 'status', '--field=id']) - try: - description = gcl.GetIssueDescription(int(issue)) - except ValueError: + issue = BackquoteAsInteger(['git', 'cl', 'status', '--field=id']) + patchset = BackquoteAsInteger(['git', 'cl', 'status', '--field=patch']) + if issue: + description = gcl.GetIssueDescription(issue) + else: description = m.group(2) - patchset = None self.change = presubmit_support.GitChange(name, description, absroot, files, issue, patchset)