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: |