| 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."""
|
|
|