Commit 5eb757a7 authored by Haiyang Pan's avatar Haiyang Pan Committed by Commit Bot

Skip non-text files for CheckDoNotSubmitInFiles

Bug: 1017286
Change-Id: Ibb9f2c94eb87024a3d9b9f334ffa5f8e2429b368
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1881377Reviewed-by: 's avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Haiyang Pan <hypan@google.com>
parent fea4a254
......@@ -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)]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment