Chromium Code Reviews| Index: git_cl.py |
| diff --git a/git_cl.py b/git_cl.py |
| index 244259df3d5b8876c9e353b4d066dcabdba79ba3..8acddba25eb74ae14d110a370d118099cb71d643 100755 |
| --- a/git_cl.py |
| +++ b/git_cl.py |
| @@ -39,6 +39,7 @@ 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/UsingNewGit' |
| +CHANGE_ID_STR = 'Change-Id:' |
|
cmp
2012/10/20 22:42:31
drop _STR from variable name (here and below)
Siva Chandra
2012/10/22 07:13:56
Done.
|
| # Initialized in main() |
| @@ -988,6 +989,20 @@ 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 CHANGE_ID_STR in new_log_desc: |
| + print "git-cl: Added Change-Id to commit message." |
|
cmp
2012/10/20 22:42:31
use single quotes here rather than double quotes
Siva Chandra
2012/10/22 07:13:56
Done.
|
| + else: |
| + sys.stderr.write("ERROR: Gerrit commit-msg hook not available.\n") |
|
cmp
2012/10/20 22:42:31
use:
print >>sys.stderr, 'ERROR: Gerrit commit-m
Siva Chandra
2012/10/22 07:13:56
Done.
|
| + |
| + |
| def GerritUpload(options, args, cl): |
| """upload the current branch to gerrit.""" |
| # We assume the remote called "origin" is the one we want. |
| @@ -998,6 +1013,8 @@ def GerritUpload(options, args, cl): |
| branch = options.target_branch |
| log_desc = options.message or CreateDescriptionFromLog(args) |
| + if CHANGE_ID_STR not in log_desc: |
| + AddChangeIdToCommitMessage(options, args) |
| if options.reviewers: |
| log_desc += '\nR=' + options.reviewers |
| change_desc = ChangeDescription(log_desc, options.reviewers) |