Fix public_deps presubmit and gn format fighting each other.

I changed stuff in test/BUILD.gn, but the suggested formatting broke
the presubmit. I tried rewriting the presubmit so it checks the
previous line as well, but that turned out to be hard.

Please try to enable this presubmit on ALL lines in a changed file.
Presubmits that only work on changed lines are really confusing.

Bug: None
Change-Id: I2386c765367681f683d82739293bc8bc8a873a7b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167926
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30420}
This commit is contained in:
Patrik Höglund
2020-01-30 11:32:33 +01:00
committed by Commit Bot
parent 83245bde3d
commit 81c7a60961
2 changed files with 18 additions and 12 deletions

View File

@ -529,16 +529,17 @@ def CheckPublicDepsIsNotUsed(gn_files, input_api, output_api):
'because it doesn\'t map well to downstream build systems.\n'
'Used in: %s (line %d).\n'
'If you are not adding this code (e.g. you are just moving '
'existing code) or you have a good reason, you can add a '
'comment on the line that causes the problem:\n\n'
'existing code) or you have a good reason, you can add this '
'comment (verbatim) on the line that causes the problem:\n\n'
'public_deps = [ # no-presubmit-check TODO(webrtc:8603)\n')
for affected_file in gn_files:
for (line_number, affected_line) in affected_file.ChangedContents():
if ('public_deps' in affected_line
and not no_presubmit_check_re.search(affected_line)):
result.append(
output_api.PresubmitError(error_msg % (affected_file.LocalPath(),
line_number)))
if 'public_deps' in affected_line:
surpressed = no_presubmit_check_re.search(affected_line)
if not surpressed:
result.append(
output_api.PresubmitError(error_msg % (affected_file.LocalPath(),
line_number)))
return result