@ -19,6 +19,12 @@ import metadata.parse
import metadata . validation_result as vr
import metadata . validation_result as vr
_TRANSITION_PRESCRIPT = (
" The following issue should be addressed now, as it will become a "
" presubmit error (instead of warning) once third party metadata "
" validation is enforced. \n Third party metadata issue: " )
def validate_content ( content : str , source_file_dir : str ,
def validate_content ( content : str , source_file_dir : str ,
repo_root_dir : str ) - > List [ vr . ValidationResult ] :
repo_root_dir : str ) - > List [ vr . ValidationResult ] :
""" Validate the content as a metadata file.
""" Validate the content as a metadata file.
@ -129,17 +135,17 @@ def check_file(
error_messages = [ ]
error_messages = [ ]
warning_messages = [ ]
warning_messages = [ ]
for result in results :
for result in results :
message = result . get_message ( width = 60 )
# TODO(aredulla): Actually distinguish between validation errors
# TODO(aredulla): Actually distinguish between validation errors
# and warnings. The quality of metadata is currently being
# and warnings. The quality of metadata is currently being
# uplifted, but is not yet guaranteed to pass validation. So for
# uplifted, but is not yet guaranteed to pass validation. So for
# now, all validation results will be returned as warnings so
# now, all validation results will be returned as warnings so
# CLs are not blocked by invalid metadata in presubmits yet.
# CLs are not blocked by invalid metadata in presubmits yet.
# Bug: b/285453019.
# Bug: b/285453019.
# if result.is_fatal():
if result . is_fatal ( ) :
# error_messages.append(message)
message = result . get_message ( prescript = _TRANSITION_PRESCRIPT ,
# else:
width = 60 )
else :
message = result . get_message ( width = 60 )
warning_messages . append ( message )
warning_messages . append ( message )
return error_messages , warning_messages
return error_messages , warning_messages