Commit 3ec0d54f authored by jochen@chromium.org's avatar jochen@chromium.org

Indiciate the tree status in the rietveld message when bypassing hooks

BUG=none
R=iannucci@chromium.org,maruel@chromium.org

Review URL: https://codereview.chromium.org/130803004

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@244793 0039d316-1c4b-4281-b951-d872f2087c98
parent 1ce8e665
......@@ -733,13 +733,18 @@ def GenerateDiff(files):
files, GetRepositoryRoot(), full_move=False, revision=None)
def GetTreeStatus():
tree_status_url = GetCodeReviewSetting('STATUS')
return git_cl.GetTreeStatus(tree_status_url) if tree_status_url else "unset"
def OptionallyDoPresubmitChecks(change_info, committing, args):
if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"):
breakpad.SendStack(
breakpad.DEFAULT_URL + '/breakpad',
'GclHooksBypassedCommit',
'Issue %s/%s bypassed hook when committing' %
(change_info.rietveld, change_info.issue),
'Issue %s/%s bypassed hook when committing (tree status was "%s")' %
(change_info.rietveld, change_info.issue, GetTreeStatus()),
verbose=False)
return presubmit_support.PresubmitOutput()
return DoPresubmitChecks(change_info, committing, True)
......@@ -1065,7 +1070,10 @@ def CMDcommit(change_info, args):
change_info.issue, False)
patch_num = len(props['patchsets'])
comment = "Committed patchset #%d manually as r%s" % (patch_num, revision)
comment += ' (presubmit successful).' if not bypassed else '.'
if bypassed:
comment += ' (tree was closed).' if GetTreeStatus() == 'closed' else '.'
else:
comment += ' (presubmit successful).'
change_info.AddComment(comment)
return 0
......
......@@ -1750,8 +1750,8 @@ def SendUpstream(parser, args, cmd):
else:
breakpad.SendStack(
'GitClHooksBypassedCommit',
'Issue %s/%s bypassed hook when committing' %
(cl.GetRietveldServer(), cl.GetIssue()),
'Issue %s/%s bypassed hook when committing (tree status was "%s")' %
(cl.GetRietveldServer(), cl.GetIssue(), GetTreeStatus()),
verbose=False)
change_desc = ChangeDescription(options.message)
......@@ -1871,7 +1871,10 @@ def SendUpstream(parser, args, cmd):
props = cl.GetIssueProperties()
patch_num = len(props['patchsets'])
comment = "Committed patchset #%d manually as r%s" % (patch_num, revision)
comment += ' (presubmit successful).' if not options.bypass_hooks else '.'
if options.bypass_hooks:
comment += ' (tree was closed).' if GetTreeStatus() == 'closed' else '.'
else:
comment += ' (presubmit successful).'
cl.RpcServer().add_comment(cl.GetIssue(), comment)
cl.SetIssue(None)
......@@ -2023,10 +2026,10 @@ def CMDrebase(parser, args):
return subprocess2.call(['git', 'svn', 'rebase'] + args, env=env)
def GetTreeStatus():
def GetTreeStatus(url=None):
"""Fetches the tree status and returns either 'open', 'closed',
'unknown' or 'unset'."""
url = settings.GetTreeStatusUrl(error_ok=True)
url = url or settings.GetTreeStatusUrl(error_ok=True)
if url:
status = urllib2.urlopen(url).read().lower()
if status.find('closed') != -1 or status == '0':
......
......@@ -99,7 +99,7 @@ class GclUnittest(GclTestsBase):
'GenerateChangeName', 'GenerateDiff', 'GetCLs', 'GetCacheDir',
'GetCachedFile', 'GetChangelistInfoFile', 'GetChangesDir',
'GetCodeReviewSetting', 'GetFilesNotInCL', 'GetInfoDir',
'GetModifiedFiles', 'GetRepositoryRoot', 'ListFiles',
'GetModifiedFiles', 'GetRepositoryRoot', 'GetTreeStatus', 'ListFiles',
'LoadChangelistInfoForMultiple', 'MISSING_TEST_MSG',
'OptionallyDoPresubmitChecks', 'REPOSITORY_ROOT',
'RunShell', 'RunShellWithReturnCode', 'SVN',
......
......@@ -311,9 +311,10 @@ class TestGitCl(TestCase):
'config', 'branch.working.rietveldissue'],), '12345'),
((['git', 'config', 'branch.working.rietveldserver'],),
'codereview.example.com'),
((['git', 'config', 'rietveld.tree-status-url'],), ''),
(('GitClHooksBypassedCommit',
'Issue https://codereview.example.com/12345 bypassed hook when '
'committing'), None),
'committing (tree status was "unset")'), None),
]
@classmethod
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment