OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Enables directory-specific presubmit checks to run at upload and/or commit. | 6 """Enables directory-specific presubmit checks to run at upload and/or commit. |
7 """ | 7 """ |
8 | 8 |
9 __version__ = '1.8.0' | 9 __version__ = '1.8.0' |
10 | 10 |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 487 |
488 The lists will be compiled as regular expression and | 488 The lists will be compiled as regular expression and |
489 AffectedFile.LocalPath() needs to pass both list. | 489 AffectedFile.LocalPath() needs to pass both list. |
490 | 490 |
491 Note: Copy-paste this function to suit your needs or use a lambda function. | 491 Note: Copy-paste this function to suit your needs or use a lambda function. |
492 """ | 492 """ |
493 def Find(affected_file, items): | 493 def Find(affected_file, items): |
494 local_path = affected_file.LocalPath() | 494 local_path = affected_file.LocalPath() |
495 for item in items: | 495 for item in items: |
496 if self.re.match(item, local_path): | 496 if self.re.match(item, local_path): |
497 logging.debug("%s matched %s", item, local_path) | |
498 return True | 497 return True |
499 return False | 498 return False |
500 return (Find(affected_file, white_list or self.DEFAULT_WHITE_LIST) and | 499 return (Find(affected_file, white_list or self.DEFAULT_WHITE_LIST) and |
501 not Find(affected_file, black_list or self.DEFAULT_BLACK_LIST)) | 500 not Find(affected_file, black_list or self.DEFAULT_BLACK_LIST)) |
502 | 501 |
503 def AffectedSourceFiles(self, source_file): | 502 def AffectedSourceFiles(self, source_file): |
504 """Filter the list of AffectedTextFiles by the function source_file. | 503 """Filter the list of AffectedTextFiles by the function source_file. |
505 | 504 |
506 If source_file is None, InputApi.FilterSourceFile() is used. | 505 If source_file is None, InputApi.FilterSourceFile() is used. |
507 """ | 506 """ |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 return 2 | 1805 return 2 |
1807 | 1806 |
1808 | 1807 |
1809 if __name__ == '__main__': | 1808 if __name__ == '__main__': |
1810 fix_encoding.fix_encoding() | 1809 fix_encoding.fix_encoding() |
1811 try: | 1810 try: |
1812 sys.exit(main()) | 1811 sys.exit(main()) |
1813 except KeyboardInterrupt: | 1812 except KeyboardInterrupt: |
1814 sys.stderr.write('interrupted\n') | 1813 sys.stderr.write('interrupted\n') |
1815 sys.exit(2) | 1814 sys.exit(2) |
OLD | NEW |