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
experimental/szager/collated-output
jochen@chromium.org 12 years ago
parent 1ce8e665e7
commit 3ec0d54fd7

@ -733,13 +733,18 @@ def GenerateDiff(files):
files, GetRepositoryRoot(), full_move=False, revision=None) 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): def OptionallyDoPresubmitChecks(change_info, committing, args):
if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"): if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"):
breakpad.SendStack( breakpad.SendStack(
breakpad.DEFAULT_URL + '/breakpad', breakpad.DEFAULT_URL + '/breakpad',
'GclHooksBypassedCommit', 'GclHooksBypassedCommit',
'Issue %s/%s bypassed hook when committing' % 'Issue %s/%s bypassed hook when committing (tree status was "%s")' %
(change_info.rietveld, change_info.issue), (change_info.rietveld, change_info.issue, GetTreeStatus()),
verbose=False) verbose=False)
return presubmit_support.PresubmitOutput() return presubmit_support.PresubmitOutput()
return DoPresubmitChecks(change_info, committing, True) return DoPresubmitChecks(change_info, committing, True)
@ -1065,7 +1070,10 @@ def CMDcommit(change_info, args):
change_info.issue, False) change_info.issue, False)
patch_num = len(props['patchsets']) patch_num = len(props['patchsets'])
comment = "Committed patchset #%d manually as r%s" % (patch_num, revision) 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) change_info.AddComment(comment)
return 0 return 0

@ -1750,8 +1750,8 @@ def SendUpstream(parser, args, cmd):
else: else:
breakpad.SendStack( breakpad.SendStack(
'GitClHooksBypassedCommit', 'GitClHooksBypassedCommit',
'Issue %s/%s bypassed hook when committing' % 'Issue %s/%s bypassed hook when committing (tree status was "%s")' %
(cl.GetRietveldServer(), cl.GetIssue()), (cl.GetRietveldServer(), cl.GetIssue(), GetTreeStatus()),
verbose=False) verbose=False)
change_desc = ChangeDescription(options.message) change_desc = ChangeDescription(options.message)
@ -1871,7 +1871,10 @@ def SendUpstream(parser, args, cmd):
props = cl.GetIssueProperties() props = cl.GetIssueProperties()
patch_num = len(props['patchsets']) patch_num = len(props['patchsets'])
comment = "Committed patchset #%d manually as r%s" % (patch_num, revision) 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.RpcServer().add_comment(cl.GetIssue(), comment)
cl.SetIssue(None) cl.SetIssue(None)
@ -2023,10 +2026,10 @@ def CMDrebase(parser, args):
return subprocess2.call(['git', 'svn', 'rebase'] + args, env=env) return subprocess2.call(['git', 'svn', 'rebase'] + args, env=env)
def GetTreeStatus(): def GetTreeStatus(url=None):
"""Fetches the tree status and returns either 'open', 'closed', """Fetches the tree status and returns either 'open', 'closed',
'unknown' or 'unset'.""" 'unknown' or 'unset'."""
url = settings.GetTreeStatusUrl(error_ok=True) url = url or settings.GetTreeStatusUrl(error_ok=True)
if url: if url:
status = urllib2.urlopen(url).read().lower() status = urllib2.urlopen(url).read().lower()
if status.find('closed') != -1 or status == '0': if status.find('closed') != -1 or status == '0':

@ -99,7 +99,7 @@ class GclUnittest(GclTestsBase):
'GenerateChangeName', 'GenerateDiff', 'GetCLs', 'GetCacheDir', 'GenerateChangeName', 'GenerateDiff', 'GetCLs', 'GetCacheDir',
'GetCachedFile', 'GetChangelistInfoFile', 'GetChangesDir', 'GetCachedFile', 'GetChangelistInfoFile', 'GetChangesDir',
'GetCodeReviewSetting', 'GetFilesNotInCL', 'GetInfoDir', 'GetCodeReviewSetting', 'GetFilesNotInCL', 'GetInfoDir',
'GetModifiedFiles', 'GetRepositoryRoot', 'ListFiles', 'GetModifiedFiles', 'GetRepositoryRoot', 'GetTreeStatus', 'ListFiles',
'LoadChangelistInfoForMultiple', 'MISSING_TEST_MSG', 'LoadChangelistInfoForMultiple', 'MISSING_TEST_MSG',
'OptionallyDoPresubmitChecks', 'REPOSITORY_ROOT', 'OptionallyDoPresubmitChecks', 'REPOSITORY_ROOT',
'RunShell', 'RunShellWithReturnCode', 'SVN', 'RunShell', 'RunShellWithReturnCode', 'SVN',

@ -311,9 +311,10 @@ class TestGitCl(TestCase):
'config', 'branch.working.rietveldissue'],), '12345'), 'config', 'branch.working.rietveldissue'],), '12345'),
((['git', 'config', 'branch.working.rietveldserver'],), ((['git', 'config', 'branch.working.rietveldserver'],),
'codereview.example.com'), 'codereview.example.com'),
((['git', 'config', 'rietveld.tree-status-url'],), ''),
(('GitClHooksBypassedCommit', (('GitClHooksBypassedCommit',
'Issue https://codereview.example.com/12345 bypassed hook when ' 'Issue https://codereview.example.com/12345 bypassed hook when '
'committing'), None), 'committing (tree status was "unset")'), None),
] ]
@classmethod @classmethod

Loading…
Cancel
Save