diff options
author | rmistry <rmistry@google.com> | 2016-09-01 13:36:31 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-01 13:36:31 -0700 |
commit | 07f0446e9a36e39814a92a1681ab59de79275651 (patch) | |
tree | f0ce604eeb6fd18a018430ab3d223f1269610a4d /PRESUBMIT.py | |
parent | 3ed18974370084bcf39a5b642c514e306b7a5626 (diff) |
Fix PostUploadHook for Gerrit issues
A gerrit change must contain the "Change-Id" at the end. This CL strips
out the changeId from the description and adds it back in at the end.
BUG=skia:5676
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2299303002
NOTRY=true
Review-Url: https://codereview.chromium.org/2299303002
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r-- | PRESUBMIT.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 38b4b5a872..c281b9a70d 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -458,6 +458,14 @@ def PostUploadHook(cl, change, output_api): issue = cl.issue if issue: original_description = cl.GetDescription() + changeIdLine = None + if cl.IsGerrit(): + # Remove Change-Id from description and add it back at the end. + regex = re.compile(r'^(Change-Id: (\w+))(\n*)\Z', re.M | re.I) + changeIdLine = re.search(regex, original_description).group(0) + original_description = re.sub(regex, '', original_description) + original_description = re.sub('\n+\Z', '\n', original_description) + new_description = original_description # Add GOLD_TRYBOT_URL if it does not exist yet. @@ -535,6 +543,9 @@ def PostUploadHook(cl, change, output_api): # If the description has changed update it. if new_description != original_description: + if changeIdLine: + # The Change-Id line must have two newlines before it. + new_description += '\n\n' + changeIdLine cl.UpdateDescription(new_description) return results |