| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Utilities for scanning source files to determine code authorship. | 5 """Utilities for scanning source files to determine code authorship. |
| 6 """ | 6 """ |
| 7 | 7 |
| 8 import itertools | 8 import itertools |
| 9 | 9 |
| 10 def ForwardSlashesToOsPathSeps(input_api, path): | 10 def ForwardSlashesToOsPathSeps(input_api, path): |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 path_join('tools', 'histograms'), | 68 path_join('tools', 'histograms'), |
| 69 # Swarming tools, doesn't exist in the snapshot | 69 # Swarming tools, doesn't exist in the snapshot |
| 70 path_join('tools', 'swarming_client'), | 70 path_join('tools', 'swarming_client'), |
| 71 # ARM sysroot, doesn't exist in the snapshot | 71 # ARM sysroot, doesn't exist in the snapshot |
| 72 path_join('chrome', 'installer', 'linux', 'debian_wheezy_arm-sysroot'), | 72 path_join('chrome', 'installer', 'linux', 'debian_wheezy_arm-sysroot'), |
| 73 # Old location (TODO(sbc): Remove this once it no longer exists on any bots) | 73 # Old location (TODO(sbc): Remove this once it no longer exists on any bots) |
| 74 path_join('arm-sysroot'), | 74 path_join('arm-sysroot'), |
| 75 # Data is not part of open source chromium, but are included on some bots. | 75 # Data is not part of open source chromium, but are included on some bots. |
| 76 path_join('data'), | 76 path_join('data'), |
| 77 # This is not part of open source chromium, but are included on some bots. | 77 # This is not part of open source chromium, but are included on some bots. |
| 78 path_join('skia', 'tools', 'clusterfuzz-data') | 78 path_join('skia', 'tools', 'clusterfuzz-data'), |
| 79 # Not shipped, only relates to Chrome for Android, but not to WebView |
| 80 path_join('clank'), |
| 79 ] | 81 ] |
| 80 excluded_dirs_list.extend(EXTRA_EXCLUDED_DIRS) | 82 excluded_dirs_list.extend(EXTRA_EXCLUDED_DIRS) |
| 81 | 83 |
| 82 # Surround the directory names with OS path separators. | 84 # Surround the directory names with OS path separators. |
| 83 dirs_blacklist = [path_join('.', d, '')[1:] for d in excluded_dirs_list if d] | 85 dirs_blacklist = [path_join('.', d, '')[1:] for d in excluded_dirs_list if d] |
| 84 def IsBlacklistedDir(d): | 86 def IsBlacklistedDir(d): |
| 85 for item in dirs_blacklist: | 87 for item in dirs_blacklist: |
| 86 if item in d: | 88 if item in d: |
| 87 return True | 89 return True |
| 88 return False | 90 return False |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 input_api: InputAPI of presubmit scripts. | 306 input_api: InputAPI of presubmit scripts. |
| 305 whitelisted_files: Whitelisted files list. | 307 whitelisted_files: Whitelisted files list. |
| 306 offending_files: Files that contain 3rd party code. | 308 offending_files: Files that contain 3rd party code. |
| 307 Returns: | 309 Returns: |
| 308 A triplet of "unknown", "missing", and "stale" file lists. | 310 A triplet of "unknown", "missing", and "stale" file lists. |
| 309 "Unknown" are files that contain 3rd party code but not whitelisted. | 311 "Unknown" are files that contain 3rd party code but not whitelisted. |
| 310 "Missing" are files that are whitelisted but doesn't really exist. | 312 "Missing" are files that are whitelisted but doesn't really exist. |
| 311 "Stale" are files that are whitelisted unnecessarily. | 313 "Stale" are files that are whitelisted unnecessarily. |
| 312 """ | 314 """ |
| 313 unknown = set(offending_files) - set(whitelisted_files) | 315 unknown = set(offending_files) - set(whitelisted_files) |
| 314 missing = [f for f in whitelisted_files if not input_api.os_path.isfile(f)] | 316 missing = [f for f in whitelisted_files if not input_api.os_path.isfile( |
| 317 input_api.os_path.join(input_api.change.RepositoryRoot(), f))] |
| 315 stale = set(whitelisted_files) - set(offending_files) - set(missing) | 318 stale = set(whitelisted_files) - set(offending_files) - set(missing) |
| 316 return (list(unknown), missing, list(stale)) | 319 return (list(unknown), missing, list(stale)) |
| 317 | 320 |
| 318 | 321 |
| 319 def _GetDeletedContents(affected_file): | 322 def _GetDeletedContents(affected_file): |
| 320 """Returns a list of all deleted lines. | 323 """Returns a list of all deleted lines. |
| 321 AffectedFile class from presubmit_support is lacking this functionality. | 324 AffectedFile class from presubmit_support is lacking this functionality. |
| 322 """ | 325 """ |
| 323 deleted_lines = [] | 326 deleted_lines = [] |
| 324 for line in affected_file.GenerateScmDiff().splitlines(): | 327 for line in affected_file.GenerateScmDiff().splitlines(): |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 'The following files are whitelisted in %s, ' \ | 384 'The following files are whitelisted in %s, ' \ |
| 382 'but do not exist or not files:' % _GetWhitelistFileName(input_api), | 385 'but do not exist or not files:' % _GetWhitelistFileName(input_api), |
| 383 sorted(missing_files))) | 386 sorted(missing_files))) |
| 384 if stale_files: | 387 if stale_files: |
| 385 results.append(output_api.PresubmitPromptWarning( | 388 results.append(output_api.PresubmitPromptWarning( |
| 386 'The following files are whitelisted unnecessarily. You must ' \ | 389 'The following files are whitelisted unnecessarily. You must ' \ |
| 387 'remove the following files from the whitelist file ' \ | 390 'remove the following files from the whitelist file ' \ |
| 388 '%s:' % _GetWhitelistFileName(input_api), | 391 '%s:' % _GetWhitelistFileName(input_api), |
| 389 sorted(stale_files))) | 392 sorted(stale_files))) |
| 390 return results | 393 return results |
| OLD | NEW |