Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Chromium_Depot_tools
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
Chromium_Depot_tools
Commits
0b67044c
Commit
0b67044c
authored
Jun 07, 2016
by
seanmccullough
Committed by
Commit bot
Jun 07, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[depot_tools] Add gendered pronoun presubmit check.
Review-Url:
https://codereview.chromium.org/2046003002
parent
16e0b4e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
presubmit_canned_checks.py
presubmit_canned_checks.py
+20
-0
presubmit_unittest.py
tests/presubmit_unittest.py
+1
-0
No files found.
presubmit_canned_checks.py
View file @
0b67044c
...
...
@@ -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."""
...
...
tests/presubmit_unittest.py
View file @
0b67044c
...
...
@@ -1876,6 +1876,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
'CheckChangeWasUploaded'
,
'CheckDoNotSubmit'
,
'CheckDoNotSubmitInDescription'
,
'CheckDoNotSubmitInFiles'
,
'CheckGenderNeutral'
,
'CheckLongLines'
,
'CheckTreeIsOpen'
,
'PanProjectChecks'
,
'CheckLicense'
,
'CheckOwners'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment