Commit a87a02de authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[Sync] Adapt PRESUBMIT to a change in sync.proto

The problem came with CL
https://chromium-review.googlesource.com/c/chromium/src/+/1129140.

Bug: 866876
Change-Id: I00c6a6464b6cd8a879c0c7bb72c03bc221137043
Reviewed-on: https://chromium-review.googlesource.com/1148388Reviewed-by: default avatarMohamed Amir Yosef <mamir@chromium.org>
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577585}
parent 78b63489
......@@ -48,7 +48,7 @@ FIELD_NUMBER_PREFIX = 'sync_pb::EntitySpecifics::k'
# Start and end regexes for finding the EntitySpecifics definition in
# sync.proto.
PROTO_DEFINITION_START_PATTERN = '^message EntitySpecifics'
PROTO_DEFINITION_START_PATTERN = '^ oneof specifics_variant \{'
PROTO_DEFINITION_END_PATTERN = '^\}'
# Start and end regexes for finding the ModelTypeInfoMap definition
......@@ -60,6 +60,7 @@ MODEL_TYPE_END_PATTERN = '^\};'
# model_type.cc is where the ModelTypeInfoMap is
# sync.proto is where the proto definitions for ModelTypes are.
PROTO_FILE_PATH = './protocol/sync.proto'
PROTO_FILE_NAME = 'sync.proto'
MODEL_TYPE_FILE_NAME = 'model_type.cc'
SYNC_SOURCE_FILES = (r'^components[\\/]sync[\\/].*\.(cc|h)$',)
......@@ -214,12 +215,11 @@ def ParseSyncProtoFieldIdentifiers(input_api, sync_proto_path):
if '//' in line or len(split_proto_line) < 3:
continue
field_typename = split_proto_line[1]
field_identifier = split_proto_line[2]
field_typename = split_proto_line[0]
field_identifier = split_proto_line[1]
proto_field_definitions[field_typename] = field_identifier
return proto_field_definitions
def StripTrailingS(string):
return string.rstrip('sS')
......@@ -384,8 +384,9 @@ def CheckChanges(input_api, output_api):
results = []
results += CheckChangeLintsClean(input_api, output_api)
for f in input_api.AffectedFiles():
if f.LocalPath().endswith(MODEL_TYPE_FILE_NAME):
return CheckModelTypeInfoMap(input_api, output_api, f)
if (f.LocalPath().endswith(MODEL_TYPE_FILE_NAME) or
f.LocalPath().endswith(PROTO_FILE_NAME)):
results += CheckModelTypeInfoMap(input_api, output_api, f)
return results
def CheckChangeOnUpload(input_api, output_api):
......
......@@ -70,16 +70,19 @@ class MockFile(object):
# test presubmit parsing of EntitySpecifics definition in that file.
MOCK_PROTOFILE_CONTENTS = ('\n'
'message EntitySpecifics {\n'
'//comment\n'
' //comment\n'
'\n'
'optional AutofillSpecifics autofill = 123;\n'
'optional AppSpecifics app = 456;\n'
'optional AppSettingSpecifics app_setting = 789;\n'
'optional ExtensionSettingSpecifics extension_setting = 910;\n'
'optional ManagedUserSharedSettingSpecifics managed_user_shared_setting'
' oneof specifics_variant {\n'
' AutofillSpecifics autofill = 123;\n'
' AppSpecifics app = 456;\n'
' AppSettingSpecifics app_setting = 789;\n'
' ExtensionSettingSpecifics extension_setting = 910;\n'
' ManagedUserSharedSettingSpecifics managed_user_shared_setting'
' = 915;\n'
'//comment\n'
'}\n')
' //comment\n'
' }\n'
'}\n'
)
# Format string used as the contents of a mock model_type.cc
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment