Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Unified Diff: git_cl.py

Issue 1763593002: git cl for Gerrit: make --squash generate Change-Id directly. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@G0825
Patch Set: rebase for test fixes Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index c5efc980bb6e1d98555c0c75f9133363774146d8..c4a8227b828c5043460b674dd3d57816bcf58c06 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -64,7 +64,6 @@ DEFAULT_SERVER = 'https://codereview.appspot.com'
POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s'
DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup'
GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingGit'
-CHANGE_ID = 'Change-Id:'
REFS_THAT_ALIAS_TO_OTHER_REFS = {
'refs/remotes/origin/lkgr': 'refs/remotes/origin/master',
'refs/remotes/origin/lkcr': 'refs/remotes/origin/master',
@@ -2209,40 +2208,17 @@ def GerritUpload(options, args, cl, change):
if not message:
if not options.force:
change_desc.prompt()
-
- if CHANGE_ID not in change_desc.description:
- # Run the commit-msg hook without modifying the head commit by writing
- # the commit message to a temporary file and running the hook over it,
- # then reading the file back in.
- commit_msg_hook = os.path.join(settings.GetRoot(), '.git', 'hooks',
- 'commit-msg')
- file_handle, msg_file = tempfile.mkstemp(text=True,
- prefix='commit_msg')
- logging.debug("%s %s", file_handle, msg_file)
- try:
- try:
- try:
- fileobj = os.fdopen(file_handle, 'w')
- except OSError:
- # if fdopen fails, file_handle remains open.
- # See https://docs.python.org/2/library/os.html#os.fdopen.
- os.close(file_handle)
- raise
- with fileobj:
- # This will close the file_handle.
- fileobj.write(change_desc.description)
- logging.debug("%s %s finish editing", file_handle, msg_file)
- finally:
- RunCommand([commit_msg_hook, msg_file])
- change_desc.set_description(gclient_utils.FileRead(msg_file))
- finally:
- os.remove(msg_file)
-
if not change_desc.description:
print "Description is empty; aborting."
return 1
-
message = change_desc.description
+ change_ids = git_footers.get_footer_change_id(message)
+ if len(change_ids) > 1:
+ DieWithError('too many Change-Id footers in %s branch' % shadow_branch)
+ if not change_ids:
+ message = git_footers.add_footer_change_id(
+ message, GenerateGerritChangeId(message))
+ change_desc.set_description(message)
remote, upstream_branch = cl.FetchUpstreamTuple(cl.GetBranch())
if remote is '.':
« no previous file with comments | « no previous file | tests/git_cl_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698