Commit 8930b3d6 authored by tandrii@chromium.org's avatar tandrii@chromium.org

git cl: update Gerrit todos and small nits.

R=andybons@chromium.org
BUG=579160

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299894 0039d316-1c4b-4281-b951-d872f2087c98
parent 8acd833e
......@@ -878,7 +878,10 @@ class Changelist(object):
Supports two codereview backends: Rietveld or Gerrit, selected at object
creation.
Not safe for concurrent multi-{thread,process} use.
Notes:
* Not safe for concurrent multi-{thread,process} use.
* Caches values from current branch. Therefore, re-use after branch change
with care.
"""
def __init__(self, branchref=None, issue=None, codereview=None, **kwargs):
......@@ -2362,7 +2365,8 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
if not git_footers.get_footer_change_id(change_desc.description):
DownloadGerritHook(False)
change_desc.set_description(AddChangeIdToCommitMessage(options, args))
change_desc.set_description(self._AddChangeIdToCommitMessage(options,
args))
ref_to_push = 'HEAD'
parent = '%s/%s' % (gerrit_remote, branch)
change_id = git_footers.get_footer_change_id(change_desc.description)[0]
......@@ -2432,6 +2436,19 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
ref_to_push])
return 0
def _AddChangeIdToCommitMessage(self, options, args):
"""Re-commits using the current message, assumes the commit hook is in
place.
"""
log_desc = options.message or CreateDescriptionFromLog(args)
git_command = ['commit', '--amend', '-m', log_desc]
RunGit(git_command)
new_log_desc = CreateDescriptionFromLog(args)
if git_footers.get_footer_change_id(new_log_desc):
print 'git-cl: Added Change-Id to commit message.'
return new_log_desc
else:
print >> sys.stderr, 'ERROR: Gerrit commit-msg hook not available.'
_CODEREVIEW_IMPLEMENTATIONS = {
......@@ -2730,8 +2747,8 @@ def CMDconfig(parser, args):
"""Edits configuration for this tree."""
print('WARNING: git cl config works for Rietveld only.\n'
'For Gerrit, see http://crbug.com/579160.')
# TODO(tandrii): add Gerrit support as part of http://crbug.com/579160.
'For Gerrit, see http://crbug.com/603116.')
# TODO(tandrii): add Gerrit support as part of http://crbug.com/603116.
parser.add_option('--activate-update', action='store_true',
help='activate auto-updating [rietveld] section in '
'.git/config')
......@@ -3260,21 +3277,6 @@ def CMDpresubmit(parser, args):
return 0
def AddChangeIdToCommitMessage(options, args):
"""Re-commits using the current message, assumes the commit hook is in
place.
"""
log_desc = options.message or CreateDescriptionFromLog(args)
git_command = ['commit', '--amend', '-m', log_desc]
RunGit(git_command)
new_log_desc = CreateDescriptionFromLog(args)
if git_footers.get_footer_change_id(new_log_desc):
print 'git-cl: Added Change-Id to commit message.'
return new_log_desc
else:
print >> sys.stderr, 'ERROR: Gerrit commit-msg hook not available.'
def GenerateGerritChangeId(message):
"""Returns Ixxxxxx...xxx change id.
......
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