Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 import json | 10 import json |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 import rietveld | 32 import rietveld |
| 33 import scm | 33 import scm |
| 34 import subprocess2 | 34 import subprocess2 |
| 35 import watchlists | 35 import watchlists |
| 36 | 36 |
| 37 | 37 |
| 38 DEFAULT_SERVER = 'https://codereview.appspot.com' | 38 DEFAULT_SERVER = 'https://codereview.appspot.com' |
| 39 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' | 39 POSTUPSTREAM_HOOK_PATTERN = '.git/hooks/post-cl-%s' |
| 40 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' | 40 DESCRIPTION_BACKUP_FILE = '~/.git_cl_description_backup' |
| 41 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit' | 41 GIT_INSTRUCTIONS_URL = 'http://code.google.com/p/chromium/wiki/UsingNewGit' |
| 42 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.
| |
| 42 | 43 |
| 43 | 44 |
| 44 # Initialized in main() | 45 # Initialized in main() |
| 45 settings = None | 46 settings = None |
| 46 | 47 |
| 47 | 48 |
| 48 def DieWithError(message): | 49 def DieWithError(message): |
| 49 print >> sys.stderr, message | 50 print >> sys.stderr, message |
| 50 sys.exit(1) | 51 sys.exit(1) |
| 51 | 52 |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 981 else: | 982 else: |
| 982 # Default to diffing against the "upstream" branch. | 983 # Default to diffing against the "upstream" branch. |
| 983 base_branch = cl.GetUpstreamBranch() | 984 base_branch = cl.GetUpstreamBranch() |
| 984 | 985 |
| 985 cl.RunHook(committing=not options.upload, upstream_branch=base_branch, | 986 cl.RunHook(committing=not options.upload, upstream_branch=base_branch, |
| 986 may_prompt=False, verbose=options.verbose, | 987 may_prompt=False, verbose=options.verbose, |
| 987 author=None) | 988 author=None) |
| 988 return 0 | 989 return 0 |
| 989 | 990 |
| 990 | 991 |
| 992 def AddChangeIdToCommitMessage(options, args): | |
| 993 """Re-commits using the current message, assumes the commit hook is in | |
| 994 place. | |
| 995 """ | |
| 996 log_desc = options.message or CreateDescriptionFromLog(args) | |
| 997 git_command = ['commit', '--amend', '-m', log_desc] | |
| 998 RunGit(git_command) | |
| 999 new_log_desc = CreateDescriptionFromLog(args) | |
| 1000 if CHANGE_ID_STR in new_log_desc: | |
| 1001 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.
| |
| 1002 else: | |
| 1003 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.
| |
| 1004 | |
| 1005 | |
| 991 def GerritUpload(options, args, cl): | 1006 def GerritUpload(options, args, cl): |
| 992 """upload the current branch to gerrit.""" | 1007 """upload the current branch to gerrit.""" |
| 993 # We assume the remote called "origin" is the one we want. | 1008 # We assume the remote called "origin" is the one we want. |
| 994 # It is probably not worthwhile to support different workflows. | 1009 # It is probably not worthwhile to support different workflows. |
| 995 remote = 'origin' | 1010 remote = 'origin' |
| 996 branch = 'master' | 1011 branch = 'master' |
| 997 if options.target_branch: | 1012 if options.target_branch: |
| 998 branch = options.target_branch | 1013 branch = options.target_branch |
| 999 | 1014 |
| 1000 log_desc = options.message or CreateDescriptionFromLog(args) | 1015 log_desc = options.message or CreateDescriptionFromLog(args) |
| 1016 if CHANGE_ID_STR not in log_desc: | |
| 1017 AddChangeIdToCommitMessage(options, args) | |
| 1001 if options.reviewers: | 1018 if options.reviewers: |
| 1002 log_desc += '\nR=' + options.reviewers | 1019 log_desc += '\nR=' + options.reviewers |
| 1003 change_desc = ChangeDescription(log_desc, options.reviewers) | 1020 change_desc = ChangeDescription(log_desc, options.reviewers) |
| 1004 change_desc.ParseDescription() | 1021 change_desc.ParseDescription() |
| 1005 if change_desc.IsEmpty(): | 1022 if change_desc.IsEmpty(): |
| 1006 print "Description is empty; aborting." | 1023 print "Description is empty; aborting." |
| 1007 return 1 | 1024 return 1 |
| 1008 | 1025 |
| 1009 receive_options = [] | 1026 receive_options = [] |
| 1010 cc = cl.GetCCList().split(',') | 1027 cc = cl.GetCCList().split(',') |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1758 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1775 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1759 | 1776 |
| 1760 # Not a known command. Default to help. | 1777 # Not a known command. Default to help. |
| 1761 GenUsage(parser, 'help') | 1778 GenUsage(parser, 'help') |
| 1762 return CMDhelp(parser, argv) | 1779 return CMDhelp(parser, argv) |
| 1763 | 1780 |
| 1764 | 1781 |
| 1765 if __name__ == '__main__': | 1782 if __name__ == '__main__': |
| 1766 fix_encoding.fix_encoding() | 1783 fix_encoding.fix_encoding() |
| 1767 sys.exit(main(sys.argv[1:])) | 1784 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |