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

Side by Side Diff: components/sync/PRESUBMIT.py

Issue 2662453008: [Sync] Fix sync lint errors/includes, update presubmit. (Closed)
Patch Set: Rebase Created 3 years, 10 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 | « components/browser_sync/PRESUBMIT.py ('k') | components/sync/base/hash_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 """Presubmit script for sync component. 5 """Presubmit script for sync component.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools. 8 for more details about the presubmit API built into depot_tools.
9 """ 9 """
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 MODEL_TYPE_END_PATTERN = '^\};' 54 MODEL_TYPE_END_PATTERN = '^\};'
55 55
56 # Strings relating to files we'll need to read. 56 # Strings relating to files we'll need to read.
57 # model_type.cc is where the ModelTypeInfoMap is 57 # model_type.cc is where the ModelTypeInfoMap is
58 # sync.proto is where the proto definitions for ModelTypes are. 58 # sync.proto is where the proto definitions for ModelTypes are.
59 PROTO_FILE_PATH = './protocol/sync.proto' 59 PROTO_FILE_PATH = './protocol/sync.proto'
60 MODEL_TYPE_FILE_NAME = 'model_type.cc' 60 MODEL_TYPE_FILE_NAME = 'model_type.cc'
61 61
62 SYNC_SOURCE_FILES = (r'^components[\\/]sync[\\/].*\.(cc|h)$',) 62 SYNC_SOURCE_FILES = (r'^components[\\/]sync[\\/].*\.(cc|h)$',)
63 63
64 # The wrapper around lint that is called below disables a set of filters if the
65 # passed filter evaluates to false. Pass a junk filter to avoid this behavior.
66 LINT_FILTERS = ['+fake/filter']
67
64 def CheckModelTypeInfoMap(input_api, output_api, model_type_file): 68 def CheckModelTypeInfoMap(input_api, output_api, model_type_file):
65 """Checks the kModelTypeInfoMap in model_type.cc follows conventions. 69 """Checks the kModelTypeInfoMap in model_type.cc follows conventions.
66 Checks that the kModelTypeInfoMap follows the below rules: 70 Checks that the kModelTypeInfoMap follows the below rules:
67 1) The model type string should match the model type name, but with 71 1) The model type string should match the model type name, but with
68 only the first letter capitalized and spaces instead of underscores. 72 only the first letter capitalized and spaces instead of underscores.
69 2) The root tag should be the same as the model type but all lowercase. 73 2) The root tag should be the same as the model type but all lowercase.
70 3) The notification type should match the proto message name. 74 3) The notification type should match the proto message name.
71 4) No duplicate data across model types. 75 4) No duplicate data across model types.
72 Args: 76 Args:
73 input_api: presubmit_support InputApi instance 77 input_api: presubmit_support InputApi instance
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 FieldNumberToPrototypeString('EntitySpecifics::kAppFieldNumber') 363 FieldNumberToPrototypeString('EntitySpecifics::kAppFieldNumber')
360 => 'AppSpecifics' 364 => 'AppSpecifics'
361 """ 365 """
362 return field_number.replace(FIELD_NUMBER_PREFIX, '').replace( 366 return field_number.replace(FIELD_NUMBER_PREFIX, '').replace(
363 'FieldNumber', 'Specifics').replace( 367 'FieldNumber', 'Specifics').replace(
364 'AppNotificationSpecifics', 'AppNotification') 368 'AppNotificationSpecifics', 'AppNotification')
365 369
366 def CheckChangeLintsClean(input_api, output_api): 370 def CheckChangeLintsClean(input_api, output_api):
367 source_filter = lambda x: input_api.FilterSourceFile( 371 source_filter = lambda x: input_api.FilterSourceFile(
368 x, white_list=SYNC_SOURCE_FILES, black_list=None) 372 x, white_list=SYNC_SOURCE_FILES, black_list=None)
369
370 return input_api.canned_checks.CheckChangeLintsClean( 373 return input_api.canned_checks.CheckChangeLintsClean(
371 input_api, output_api, source_filter, lint_filters=[], verbose_level=1) 374 input_api, output_api, source_filter, lint_filters=LINT_FILTERS,
375 verbose_level=1)
372 376
373 def CheckChanges(input_api, output_api): 377 def CheckChanges(input_api, output_api):
374 results = [] 378 results = []
375 results += CheckChangeLintsClean(input_api, output_api) 379 results += CheckChangeLintsClean(input_api, output_api)
376 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api) 380 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api)
377 for f in input_api.AffectedFiles(): 381 for f in input_api.AffectedFiles():
378 if f.LocalPath().endswith(MODEL_TYPE_FILE_NAME): 382 if f.LocalPath().endswith(MODEL_TYPE_FILE_NAME):
379 return CheckModelTypeInfoMap(input_api, output_api, f) 383 return CheckModelTypeInfoMap(input_api, output_api, f)
380 return results 384 return results
381 385
382 def CheckChangeOnUpload(input_api, output_api): 386 def CheckChangeOnUpload(input_api, output_api):
383 return CheckChanges(input_api, output_api) 387 return CheckChanges(input_api, output_api)
384 388
385 def CheckChangeOnCommit(input_api, output_api): 389 def CheckChangeOnCommit(input_api, output_api):
386 return CheckChanges(input_api, output_api) 390 return CheckChanges(input_api, output_api)
OLDNEW
« no previous file with comments | « components/browser_sync/PRESUBMIT.py ('k') | components/sync/base/hash_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698