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

Side by Side Diff: git_cl/git_cl.py

Issue 6575036: Add support for git cl upload --cc foo@example.com (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/git_cl
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # git-cl -- a git-command for integrating reviews on Rietveld 2 # git-cl -- a git-command for integrating reviews on Rietveld
3 # Copyright (C) 2008 Evan Martin <martine@danga.com> 3 # Copyright (C) 2008 Evan Martin <martine@danga.com>
4 4
5 import errno 5 import errno
6 import logging 6 import logging
7 import optparse 7 import optparse
8 import os 8 import os
9 import re 9 import re
10 import subprocess 10 import subprocess
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 self.default_server = FixUrl(self._GetConfig( 130 self.default_server = FixUrl(self._GetConfig(
131 'rietveld.server', error_message=error_message)) 131 'rietveld.server', error_message=error_message))
132 return self.default_server 132 return self.default_server
133 133
134 def GetCCList(self): 134 def GetCCList(self):
135 """Return the users cc'd on this CL. 135 """Return the users cc'd on this CL.
136 136
137 Return is a string suitable for passing to gcl with the --cc flag. 137 Return is a string suitable for passing to gcl with the --cc flag.
138 """ 138 """
139 if self.cc is None: 139 if self.cc is None:
140 self.cc = self._GetConfig('rietveld.cc', error_ok=True) 140 base_cc = self._GetConfig('rietveld.cc', error_ok=True)
141 more_cc = self._GetConfig('rietveld.extracc', error_ok=True) 141 more_cc = self._GetConfig('rietveld.extracc', error_ok=True)
142 if more_cc is not None: 142 self.cc = ','.join(filter(None, (base_cc, more_cc))) or ''
143 self.cc += ',' + more_cc
144 return self.cc 143 return self.cc
145 144
146 def GetRoot(self): 145 def GetRoot(self):
147 if not self.root: 146 if not self.root:
148 self.root = os.path.abspath(RunGit(['rev-parse', '--show-cdup']).strip()) 147 self.root = os.path.abspath(RunGit(['rev-parse', '--show-cdup']).strip())
149 return self.root 148 return self.root
150 149
151 def GetIsGitSvn(self): 150 def GetIsGitSvn(self):
152 """Return true if this repo looks like it's using git-svn.""" 151 """Return true if this repo looks like it's using git-svn."""
153 if self.is_git_svn is None: 152 if self.is_git_svn is None:
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 702
704 703
705 @usage('[args to "git diff"]') 704 @usage('[args to "git diff"]')
706 def CMDupload(parser, args): 705 def CMDupload(parser, args):
707 """upload the current changelist to codereview""" 706 """upload the current changelist to codereview"""
708 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks', 707 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks',
709 help='bypass upload presubmit hook') 708 help='bypass upload presubmit hook')
710 parser.add_option('-m', dest='message', help='message for patch') 709 parser.add_option('-m', dest='message', help='message for patch')
711 parser.add_option('-r', '--reviewers', 710 parser.add_option('-r', '--reviewers',
712 help='reviewer email addresses') 711 help='reviewer email addresses')
712 parser.add_option('--cc',
713 help='cc email addresses')
713 parser.add_option('--send-mail', action='store_true', 714 parser.add_option('--send-mail', action='store_true',
714 help='send email to reviewer immediately') 715 help='send email to reviewer immediately')
715 parser.add_option("--emulate_svn_auto_props", action="store_true", 716 parser.add_option("--emulate_svn_auto_props", action="store_true",
716 dest="emulate_svn_auto_props", 717 dest="emulate_svn_auto_props",
717 help="Emulate Subversion's auto properties feature.") 718 help="Emulate Subversion's auto properties feature.")
718 parser.add_option("--desc_from_logs", action="store_true", 719 parser.add_option("--desc_from_logs", action="store_true",
719 dest="from_logs", 720 dest="from_logs",
720 help="""Squashes git commit logs into change description and 721 help="""Squashes git commit logs into change description and
721 uses message as subject""") 722 uses message as subject""")
722 (options, args) = parser.parse_args(args) 723 (options, args) = parser.parse_args(args)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 log_desc += '\nTEST=' 787 log_desc += '\nTEST='
787 change_desc = UserEditedLog(initial_text + log_desc) 788 change_desc = UserEditedLog(initial_text + log_desc)
788 subject = '' 789 subject = ''
789 if change_desc: 790 if change_desc:
790 subject = change_desc.splitlines()[0] 791 subject = change_desc.splitlines()[0]
791 if not change_desc: 792 if not change_desc:
792 print "Description is empty; aborting." 793 print "Description is empty; aborting."
793 return 1 794 return 1
794 upload_args.extend(['--message', subject]) 795 upload_args.extend(['--message', subject])
795 upload_args.extend(['--description', change_desc]) 796 upload_args.extend(['--description', change_desc])
796 upload_args.extend(['--cc', settings.GetCCList()]) 797 cc = ','.join(filter(None, (settings.GetCCList(), options.cc)))
798 if cc:
799 upload_args.extend(['--cc', cc])
797 800
798 # Include the upstream repo's URL in the change -- this is useful for 801 # Include the upstream repo's URL in the change -- this is useful for
799 # projects that have their source spread across multiple repos. 802 # projects that have their source spread across multiple repos.
800 remote_url = None 803 remote_url = None
801 if settings.GetIsGitSvn(): 804 if settings.GetIsGitSvn():
802 data = RunGit(['svn', 'info']) 805 data = RunGit(['svn', 'info'])
803 if data: 806 if data:
804 keys = dict(line.split(': ', 1) for line in data.splitlines() 807 keys = dict(line.split(': ', 1) for line in data.splitlines()
805 if ': ' in line) 808 if ': ' in line)
806 remote_url = keys.get('URL', None) 809 remote_url = keys.get('URL', None)
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 1272 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
1270 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 1273 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
1271 1274
1272 # Not a known command. Default to help. 1275 # Not a known command. Default to help.
1273 GenUsage(parser, 'help') 1276 GenUsage(parser, 'help')
1274 return CMDhelp(parser, argv) 1277 return CMDhelp(parser, argv)
1275 1278
1276 1279
1277 if __name__ == '__main__': 1280 if __name__ == '__main__':
1278 sys.exit(main(sys.argv[1:])) 1281 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698