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

Unified Diff: PRESUBMIT.py

Issue 1004733009: Add post upload hook to substitute hashtags for their mapped text (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Typo Created 5 years, 9 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
« HASHTAGS ('K') | « HASHTAGS ('k') | 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 ae5a2183162c81026e8e382e6792b75fe362cc8c..3403651780eacc416d8dc67bf45ec4e6a7e47de7 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -9,6 +9,7 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into gcl.
"""
+import csv
import fnmatch
import os
import re
@@ -362,6 +363,24 @@ def PostUploadHook(cl, change, output_api):
'Trybots do not yet work for non-master branches. '
'Automatically added \'NOTRY=true\' to the CL\'s description'))
+ # Read and process the HASHTAGS file.
+ with open('HASHTAGS', 'rb') as hashtags_csv:
+ hashtags_reader = csv.reader(hashtags_csv, delimiter=',')
+ for row in hashtags_reader:
+ if not row or row[0].startswith('#'):
+ # Ignore empty lines and comments
+ continue
+ hashtag = row[0]
+ mapped_text = row[1]
+ # Search for the hashtag in the description.
+ if re.search('#%s' % hashtag, new_description, re.M | re.I):
+ # Add the mapped text if it does not already exist in the description.
+ if not re.search(r'^%s$' % mapped_text, new_description, re.M | re.I):
+ new_description += '\n%s' % mapped_text
+ results.append(
+ output_api.PresubmitNotifyResult(
+ 'Found \'#%s\', automatically added \'%s\' to the CL\'s '
+ 'description' % (hashtag, mapped_text)))
# If the description has changed update it.
if new_description != original_description:
« HASHTAGS ('K') | « HASHTAGS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698