Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2060)

Side by Side Diff: PRESUBMIT.py

Issue 2972363002: Add presubmit check to prevent further changes to webrtc/base. (Closed)
Patch Set: Address comments. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 files.append(f) 503 files.append(f)
504 504
505 if files: 505 if files:
506 return [output_api.PresubmitError( 506 return [output_api.PresubmitError(
507 'Please avoid to use namespace `google::protobuf` directly.\n' 507 'Please avoid to use namespace `google::protobuf` directly.\n'
508 'Add a using directive in `%s` and include that header instead.' 508 'Add a using directive in `%s` and include that header instead.'
509 % proto_utils_path, files)] 509 % proto_utils_path, files)]
510 return [] 510 return []
511 511
512 512
513 def _CheckNoChangesToWebRTCBase(input_api, output_api):
514 """Checks that no changes refer to webrtc/base."""
515 problems = []
516
517 for f in input_api.AffectedFiles():
518 if os.path.join('webrtc', 'base') in f.LocalPath():
519 problems.append(' ' + f.LocalPath())
520 continue
521 for line_num, line in f.ChangedContents():
522 if 'webrtc/base' in line:
523 problems.append(' %s: %s' % (f.LocalPath(), line_num))
524
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
530
513 def _CommonChecks(input_api, output_api): 531 def _CommonChecks(input_api, output_api):
514 """Checks common to both upload and commit.""" 532 """Checks common to both upload and commit."""
515 results = [] 533 results = []
516 # Filter out files that are in objc or ios dirs from being cpplint-ed since 534 # Filter out files that are in objc or ios dirs from being cpplint-ed since
517 # they do not follow C++ lint rules. 535 # they do not follow C++ lint rules.
518 black_list = input_api.DEFAULT_BLACK_LIST + ( 536 black_list = input_api.DEFAULT_BLACK_LIST + (
519 r".*\bobjc[\\\/].*", 537 r".*\bobjc[\\\/].*",
520 r".*objc\.[hcm]+$", 538 r".*objc\.[hcm]+$",
521 r"webrtc\/build\/ios\/SDK\/.*", 539 r"webrtc\/build\/ios\/SDK\/.*",
522 ) 540 )
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api)) 589 results.extend(_CheckNoIOStreamInHeaders(input_api, output_api))
572 results.extend(_CheckNoPragmaOnce(input_api, output_api)) 590 results.extend(_CheckNoPragmaOnce(input_api, output_api))
573 results.extend(_CheckNoFRIEND_TEST(input_api, output_api)) 591 results.extend(_CheckNoFRIEND_TEST(input_api, output_api))
574 results.extend(_CheckGnChanges(input_api, output_api)) 592 results.extend(_CheckGnChanges(input_api, output_api))
575 results.extend(_CheckUnwantedDependencies(input_api, output_api)) 593 results.extend(_CheckUnwantedDependencies(input_api, output_api))
576 results.extend(_CheckJSONParseErrors(input_api, output_api)) 594 results.extend(_CheckJSONParseErrors(input_api, output_api))
577 results.extend(_RunPythonTests(input_api, output_api)) 595 results.extend(_RunPythonTests(input_api, output_api))
578 results.extend(_CheckUsageOfGoogleProtobufNamespace(input_api, output_api)) 596 results.extend(_CheckUsageOfGoogleProtobufNamespace(input_api, output_api))
579 results.extend(_CheckOrphanHeaders(input_api, output_api)) 597 results.extend(_CheckOrphanHeaders(input_api, output_api))
580 results.extend(_CheckNewLineAtTheEndOfProtoFiles(input_api, output_api)) 598 results.extend(_CheckNewLineAtTheEndOfProtoFiles(input_api, output_api))
599 results.extend(_CheckNoChangesToWebRTCBase(input_api, output_api))
581 return results 600 return results
582 601
583 602
584 def CheckChangeOnUpload(input_api, output_api): 603 def CheckChangeOnUpload(input_api, output_api):
585 results = [] 604 results = []
586 results.extend(_CommonChecks(input_api, output_api)) 605 results.extend(_CommonChecks(input_api, output_api))
587 results.extend( 606 results.extend(
588 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) 607 input_api.canned_checks.CheckGNFormatted(input_api, output_api))
589 return results 608 return results
590 609
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 results = [] 660 results = []
642 source_file_filter = lambda x: input_api.FilterSourceFile( 661 source_file_filter = lambda x: input_api.FilterSourceFile(
643 x, white_list=(r'.+\.proto$',)) 662 x, white_list=(r'.+\.proto$',))
644 for f in input_api.AffectedSourceFiles(source_file_filter): 663 for f in input_api.AffectedSourceFiles(source_file_filter):
645 file_path = f.LocalPath() 664 file_path = f.LocalPath()
646 with open(file_path) as f: 665 with open(file_path) as f:
647 lines = f.readlines() 666 lines = f.readlines()
648 if lines[-1] != '\n' or lines[-2] == '\n': 667 if lines[-1] != '\n' or lines[-2] == '\n':
649 results.append(output_api.PresubmitError(error_msg.format(file_path))) 668 results.append(output_api.PresubmitError(error_msg.format(file_path)))
650 return results 669 return results
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698