Skip non-text files for CheckDoNotSubmitInFiles

Bug: 1017286
Change-Id: Ibb9f2c94eb87024a3d9b9f334ffa5f8e2429b368
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1881377
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Haiyang Pan <hypan@google.com>
changes/77/1881377/3
Haiyang Pan 6 years ago committed by Commit Bot
parent fea4a25482
commit 5eb757a742

@ -140,8 +140,14 @@ def CheckDoNotSubmitInFiles(input_api, output_api):
# We want to check every text file, not just source files.
file_filter = lambda x : x
keyword = 'DO NOT ''SUBMIT'
errors = _FindNewViolationsOfRule(lambda _, line : keyword not in line,
input_api, file_filter)
def DoNotSubmitRule(extension, line):
try:
return keyword not in line
# Fallback to True for non-text content
except UnicodeDecodeError:
return True
errors = _FindNewViolationsOfRule(DoNotSubmitRule, input_api, file_filter)
text = '\n'.join('Found %s in %s' % (keyword, loc) for loc in errors)
if text:
return [output_api.PresubmitError(text)]

Loading…
Cancel
Save