Commit 7d1c484e authored by Dominic Battre's avatar Dominic Battre Committed by Commit Bot

Extract bug number from branch name for git cl upload

If you name your branches "bug-123-fix-foobar" or "123-fix-foobar", git cl
upload will automatically populate the "Bug: " line in the cl description with
123.

Bug: 778252
Change-Id: I5bf570d5d44e8681c552a52a8b5ed0c64ce82284
Reviewed-on: https://chromium-review.googlesource.com/738237
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
parent 105e11e2
......@@ -2902,6 +2902,12 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
title = options.title
automatic_title = False
# Extract bug number from branch name.
bug = options.bug
match = re.match(r'(?:bug|fix)[_-]?(\d+)', self.GetBranch())
if not bug and match:
bug = match.group(1)
if options.squash:
self._GerritCommitMsgHookCheck(offer_removal=not options.force)
if self.GetIssue():
......@@ -2952,7 +2958,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
confirm_or_exit(action='edit')
if not options.force:
change_desc = ChangeDescription(message)
change_desc.prompt(bug=options.bug)
change_desc.prompt(bug=bug)
message = change_desc.description
if not message:
DieWithError("Description is empty. Aborting...")
......@@ -2971,7 +2977,7 @@ class _GerritChangelistImpl(_ChangelistCodereviewBase):
change_desc = ChangeDescription(message)
if not options.force:
change_desc.prompt(bug=options.bug)
change_desc.prompt(bug=bug)
# On first upload, patchset title is always this string, while
# --title flag gets converted to first line of message.
title = 'Initial upload'
......@@ -4868,6 +4874,10 @@ def CMDupload(parser, args):
To unset run:
git config --unset branch.branch_name.skip-deps-uploads
Can also set the above globally by using the --global flag.
If the name of the checked out branch starts with "bug-" or "fix-" followed by
a bug number, this bug number is automatically populated in the CL
description.
"""
parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks',
help='bypass upload presubmit hook')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment