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

Unified Diff: PRESUBMIT.py

Issue 2299303002: Fix PostUploadHook for Gerrit issues (Closed)
Patch Set: Cleanup Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 38b4b5a8726d2b0da43ecc99d86029c793c1fa73..c281b9a70db9752946eb59acbad314556feae288 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
« 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