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

Unified Diff: git_cl.py

Issue 9233057: Update upload.py @ fae51921ad9d (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Rebase against HEAD Created 8 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 | « gcl.py ('k') | tests/gcl_unittest.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 56d86f2f024fc616369c2404ed81bcac1cab4d6f..d037e39e68c197b75e843df0dd8c35f12a44f48c 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -622,47 +622,43 @@ def GetCodereviewSettingsInteractively():
class ChangeDescription(object):
"""Contains a parsed form of the change description."""
- def __init__(self, subject, log_desc, reviewers):
- self.subject = subject
+ def __init__(self, log_desc, reviewers):
self.log_desc = log_desc
self.reviewers = reviewers
self.description = self.log_desc
- def Update(self):
- initial_text = """# Enter a description of the change.
+ def Prompt(self):
+ content = """# Enter a description of the change.
# This will displayed on the codereview site.
# The first line will also be used as the subject of the review.
"""
- initial_text += self.description
+ content += self.description
if ('\nR=' not in self.description and
'\nTBR=' not in self.description and
self.reviewers):
- initial_text += '\nR=' + self.reviewers
+ content += '\nR=' + self.reviewers
if '\nBUG=' not in self.description:
- initial_text += '\nBUG='
+ content += '\nBUG='
if '\nTEST=' not in self.description:
- initial_text += '\nTEST='
- initial_text = initial_text.rstrip('\n') + '\n'
- content = gclient_utils.RunEditor(initial_text, True)
+ content += '\nTEST='
+ content = content.rstrip('\n') + '\n'
+ content = gclient_utils.RunEditor(content, True)
if not content:
DieWithError('Running editor failed')
content = re.compile(r'^#.*$', re.MULTILINE).sub('', content).strip()
- if not content:
+ if not content.strip():
DieWithError('No CL description, aborting')
- self.ParseDescription(content)
+ self.description = content
- def ParseDescription(self, description):
+ def ParseDescription(self):
"""Updates the list of reviewers and subject from the description."""
- if not description:
- self.description = description
- return
-
- self.description = description.strip('\n') + '\n'
- self.subject = description.split('\n', 1)[0]
+ self.description = self.description.strip('\n') + '\n'
# Retrieves all reviewer lines
regexp = re.compile(r'^\s*(TBR|R)=(.+)$', re.MULTILINE)
- self.reviewers = ','.join(
+ reviewers = ','.join(
i.group(2).strip() for i in regexp.finditer(self.description))
+ if reviewers:
+ self.reviewers = reviewers
def IsEmpty(self):
return not self.description
@@ -864,12 +860,11 @@ def GerritUpload(options, args, cl):
if options.target_branch:
branch = options.target_branch
- log_desc = CreateDescriptionFromLog(args)
+ log_desc = options.message or CreateDescriptionFromLog(args)
if options.reviewers:
log_desc += '\nR=' + options.reviewers
- change_desc = ChangeDescription(options.message, log_desc,
- options.reviewers)
- change_desc.ParseDescription(log_desc)
+ change_desc = ChangeDescription(log_desc, options.reviewers)
+ change_desc.ParseDescription()
if change_desc.IsEmpty():
print "Description is empty; aborting."
return 1
@@ -902,9 +897,6 @@ def RietveldUpload(options, args, cl):
upload_args.extend(['--server', cl.GetRietveldServer()])
if options.emulate_svn_auto_props:
upload_args.append('--emulate_svn_auto_props')
- if options.from_logs and not options.message:
- print 'Must set message for subject line if using desc_from_logs'
- return 1
change_desc = None
@@ -915,18 +907,17 @@ def RietveldUpload(options, args, cl):
print ("This branch is associated with issue %s. "
"Adding patch to that issue." % cl.GetIssue())
else:
- log_desc = CreateDescriptionFromLog(args)
- change_desc = ChangeDescription(options.message, log_desc,
- options.reviewers)
- if not options.from_logs:
- change_desc.Update()
+ message = options.message or CreateDescriptionFromLog(args)
+ change_desc = ChangeDescription(message, options.reviewers)
+ if not options.force:
+ change_desc.Prompt()
+ change_desc.ParseDescription()
if change_desc.IsEmpty():
print "Description is empty; aborting."
return 1
- upload_args.extend(['--message', change_desc.subject])
- upload_args.extend(['--description', change_desc.description])
+ upload_args.extend(['--message', change_desc.description])
if change_desc.reviewers:
upload_args.extend(['--reviewers', change_desc.reviewers])
if options.send_mail:
« no previous file with comments | « gcl.py ('k') | tests/gcl_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698