Commit b85a3163 authored by iannucci@chromium.org's avatar iannucci@chromium.org

Make gcl commit/git cl dcommit append a commit notification to rietveld.

R=maruel@chromium.org
BUG=163426

Review URL: https://chromiumcodereview.appspot.com/12047089

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@178975 0039d316-1c4b-4281-b951-d872f2087c98
parent 08c77232
......@@ -393,6 +393,11 @@ class ChangeInfo(object):
"""Returns the issue description from Rietveld."""
return self.SendToRietveld('/%d/description' % self.issue)
def AddComment(self, comment):
"""Adds a comment for an issue on Rietveld.
As a side effect, this will email everyone associated with the issue."""
return self.RpcServer().add_comment(self.issue, comment)
def PrimeLint(self):
"""Do background work on Rietveld to lint the file so that the results are
ready when the issue is viewed."""
......@@ -982,6 +987,8 @@ def CMDcommit(change_info, args):
print "Nothing to commit, changelist is empty."
return 1
# OptionallyDoPresubmitChecks has a side-effect which eats these flags.
bypassed = '--no_presubmit' in args or '--force' in args
output = OptionallyDoPresubmitChecks(change_info, True, args)
if not output.should_continue():
return 1
......@@ -1038,6 +1045,9 @@ def CMDcommit(change_info, args):
elif revision:
change_info.description += "\nCommitted: " + revision
change_info.CloseIssue()
comment = "Committed manually as r%s" % revision
comment += ' (presubmit successful).' if not bypassed else '.'
change_info.AddComment(comment)
return 0
......
......@@ -1495,6 +1495,9 @@ def SendUpstream(parser, args, cmd):
print ('Closing issue '
'(you may be prompted for your codereview password)...')
cl.CloseIssue()
comment = "Committed manually as r%s" % revision
comment += ' (presubmit successful).' if not options.bypass_hooks else '.'
cl.RpcServer().add_comment(cl.GetIssue(), comment)
cl.SetIssue(0)
if retcode == 0:
......
......@@ -56,6 +56,12 @@ class GclTestsBase(SuperMoxTestBase):
change_info.reviewers = None
change_info._closed = False
change_info._deleted = False
change_info._comments_added = []
def AddComment(comment):
# pylint: disable=W0212
change_info._comments_added.append(comment)
change_info.AddComment = AddComment
def Delete():
change_info._deleted = True
......@@ -180,9 +186,10 @@ class ChangeInfoUnittest(GclTestsBase):
def testChangeInfoMembers(self):
self.mox.ReplayAll()
members = [
'CloseIssue', 'Delete', 'Exists', 'GetFiles', 'GetFileNames',
'GetLocalRoot', 'GetIssueDescription', 'Load', 'MissingTests',
'NeedsUpload', 'PrimeLint', 'RpcServer', 'Save', 'SendToRietveld',
'AddComment', 'CloseIssue', 'Delete', 'Exists', 'GetFiles',
'GetFileNames', 'GetLocalRoot', 'GetIssueDescription', 'Load',
'MissingTests', 'NeedsUpload', 'PrimeLint', 'RpcServer', 'Save',
'SendToRietveld',
'SEPARATOR',
'UpdateRietveldDescription',
'description', 'issue', 'name',
......@@ -586,6 +593,9 @@ class CMDCommitUnittest(GclTestsBase):
# pylint: disable=W0212
self.assertTrue(change_info._deleted)
self.assertTrue(change_info._closed)
self.assertEqual(
change_info._comments_added,
["Committed manually as r12345 (presubmit successful)."])
if __name__ == '__main__':
......
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