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

Unified Diff: presubmit_canned_checks.py

Issue 2046003002: [depot_tools] Add gendered pronoun presubmit check. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: test Created 4 years, 6 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 | tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index 4ef971ea34f6139fb3c74610f569ce27430fbb46..7ec058b74baba1911b4cc6613e24be628ba5a2f3 100644
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -211,6 +211,26 @@ def CheckChangeHasNoCrAndHasOnlyOneEol(input_api, output_api,
items=eof_files))
return outputs
+def CheckGenderNeutral(input_api, output_api, source_file_filter=None):
+ """Checks that there are no gendered pronouns in any of the text files to be
+ submitted.
+ """
+ gendered_re = input_api.re.compile(
+ '(^|\s|\(|\[)([Hh]e|[Hh]is|[Hh]ers?|[Hh]im|[Ss]he|[Gg]uys?)\\b')
+
+ errors = []
+ for f in input_api.AffectedFiles(include_deletes=False,
+ file_filter=source_file_filter):
+ for line_num, line in f.ChangedContents():
+ if gendered_re.search(line):
+ errors.append('%s (%d): %s' % (f.LocalPath(), line_num, line))
+
+ if len(errors):
+ return [output_api.PresubmitPromptWarning('Found a gendered pronoun in:',
+ long_text='\n'.join(errors))]
+ return []
+
+
def _ReportErrorFileAndLine(filename, line_num, dummy_line):
"""Default error formatter for _FindNewViolationsOfRule."""
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698