[MD settings] moving attached() code
[chromium-blink-merge.git] / tools / copyright_scanner / PRESUBMIT.py
blob455701ec27ceeba3a70233264a3f85411e324eec
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 def CheckChangeOnUpload(input_api, output_api):
6 return _CommonChecks(input_api, output_api)
8 def CheckChangeOnCommit(input_api, output_api):
9 return _CommonChecks(input_api, output_api)
11 def _CommonChecks(input_api, output_api):
12 """Checks common to both upload and commit."""
13 results = []
15 would_affect_tests = [
16 'PRESUBMIT.py',
17 'copyright_scanner.py',
18 'copyright_scanner_unittest.py'
20 need_to_run_unittests = False
21 for f in input_api.AffectedFiles():
22 if any(t for t in would_affect_tests if f.LocalPath().endswith(t)):
23 need_to_run_unittests = True
24 break
25 tests = [input_api.os_path.join(
26 input_api.PresubmitLocalPath(), 'copyright_scanner_unittest.py')]
27 results.extend(
28 input_api.canned_checks.RunUnitTests(input_api, output_api, tests))
29 return results