OLD | NEW |
1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
2 # | 2 # |
3 # Use of this source code is governed by a BSD-style license | 3 # Use of this source code is governed by a BSD-style license |
4 # that can be found in the LICENSE file in the root of the source | 4 # that can be found in the LICENSE file in the root of the source |
5 # tree. An additional intellectual property rights grant can be found | 5 # tree. An additional intellectual property rights grant can be found |
6 # in the file PATENTS. All contributing project authors may | 6 # in the file PATENTS. All contributing project authors may |
7 # be found in the AUTHORS file in the root of the source tree. | 7 # be found in the AUTHORS file in the root of the source tree. |
8 | 8 |
9 import json | 9 import json |
10 import os | 10 import os |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 files.append(f) | 502 files.append(f) |
503 | 503 |
504 if files: | 504 if files: |
505 return [output_api.PresubmitError( | 505 return [output_api.PresubmitError( |
506 'Please avoid to use namespace `google::protobuf` directly.\n' | 506 'Please avoid to use namespace `google::protobuf` directly.\n' |
507 'Add a using directive in `%s` and include that header instead.' | 507 'Add a using directive in `%s` and include that header instead.' |
508 % proto_utils_path, files)] | 508 % proto_utils_path, files)] |
509 return [] | 509 return [] |
510 | 510 |
511 | 511 |
512 def _CheckNoChangesToWebRTCBase(input_api, output_api): | |
513 """Checks that no changes refer to webrtc/base.""" | |
514 problems = [] | |
515 | |
516 for f in input_api.AffectedFiles(): | |
517 if os.path.join('webrtc', 'base') in f.LocalPath(): | |
518 problems.append(' ' + f.LocalPath()) | |
519 continue | |
520 for line_num, line in f.ChangedContents(): | |
521 if 'webrtc/base' in line: | |
522 problems.append(' %s: %s' % (f.LocalPath(), line_num)) | |
523 | |
524 if problems: | |
525 return [output_api.PresubmitPromptWarning( | |
526 'webrtc/base is being moved to webrtc/rtc_base (See ' | |
527 'bugs.webrtc.org/7634). Please refer to webrtc/rtc_base instead in the ' | |
528 'following files:\n' + '\n'.join(problems))] | |
529 return [] | |
530 | |
531 | |
532 def _CommonChecks(input_api, output_api): | 512 def _CommonChecks(input_api, output_api): |
533 """Checks common to both upload and commit.""" | 513 """Checks common to both upload and commit.""" |
534 results = [] | 514 results = [] |
535 # Filter out files that are in objc or ios dirs from being cpplint-ed since | 515 # Filter out files that are in objc or ios dirs from being cpplint-ed since |
536 # they do not follow C++ lint rules. | 516 # they do not follow C++ lint rules. |
537 black_list = input_api.DEFAULT_BLACK_LIST + ( | 517 black_list = input_api.DEFAULT_BLACK_LIST + ( |
538 r".*\bobjc[\\\/].*", | 518 r".*\bobjc[\\\/].*", |
539 r".*objc\.[hcm]+$", | 519 r".*objc\.[hcm]+$", |
540 r"webrtc\/build\/ios\/SDK\/.*", | 520 r"webrtc\/build\/ios\/SDK\/.*", |
541 ) | 521 ) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) | 570 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) |
591 results.extend(_CheckNoPragmaOnce(input_api, output_api)) | 571 results.extend(_CheckNoPragmaOnce(input_api, output_api)) |
592 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) | 572 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) |
593 results.extend(_CheckGnChanges(input_api, output_api)) | 573 results.extend(_CheckGnChanges(input_api, output_api)) |
594 results.extend(_CheckUnwantedDependencies(input_api, output_api)) | 574 results.extend(_CheckUnwantedDependencies(input_api, output_api)) |
595 results.extend(_CheckJSONParseErrors(input_api, output_api)) | 575 results.extend(_CheckJSONParseErrors(input_api, output_api)) |
596 results.extend(_RunPythonTests(input_api, output_api)) | 576 results.extend(_RunPythonTests(input_api, output_api)) |
597 results.extend(_CheckUsageOfGoogleProtobufNamespace(input_api, output_api)) | 577 results.extend(_CheckUsageOfGoogleProtobufNamespace(input_api, output_api)) |
598 results.extend(_CheckOrphanHeaders(input_api, output_api)) | 578 results.extend(_CheckOrphanHeaders(input_api, output_api)) |
599 results.extend(_CheckNewLineAtTheEndOfProtoFiles(input_api, output_api)) | 579 results.extend(_CheckNewLineAtTheEndOfProtoFiles(input_api, output_api)) |
600 results.extend(_CheckNoChangesToWebRTCBase(input_api, output_api)) | |
601 return results | 580 return results |
602 | 581 |
603 | 582 |
604 def CheckChangeOnUpload(input_api, output_api): | 583 def CheckChangeOnUpload(input_api, output_api): |
605 results = [] | 584 results = [] |
606 results.extend(_CommonChecks(input_api, output_api)) | 585 results.extend(_CommonChecks(input_api, output_api)) |
607 results.extend( | 586 results.extend( |
608 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) | 587 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) |
609 return results | 588 return results |
610 | 589 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 results = [] | 640 results = [] |
662 source_file_filter = lambda x: input_api.FilterSourceFile( | 641 source_file_filter = lambda x: input_api.FilterSourceFile( |
663 x, white_list=(r'.+\.proto$',)) | 642 x, white_list=(r'.+\.proto$',)) |
664 for f in input_api.AffectedSourceFiles(source_file_filter): | 643 for f in input_api.AffectedSourceFiles(source_file_filter): |
665 file_path = f.LocalPath() | 644 file_path = f.LocalPath() |
666 with open(file_path) as f: | 645 with open(file_path) as f: |
667 lines = f.readlines() | 646 lines = f.readlines() |
668 if lines[-1] != '\n' or lines[-2] == '\n': | 647 if lines[-1] != '\n' or lines[-2] == '\n': |
669 results.append(output_api.PresubmitError(error_msg.format(file_path))) | 648 results.append(output_api.PresubmitError(error_msg.format(file_path))) |
670 return results | 649 return results |
OLD | NEW |