From ed9a0819a4f244ad2e33ea983b7615bd7f9fb108 Mon Sep 17 00:00:00 2001 From: Anne Redulla Date: Wed, 20 Sep 2023 03:08:25 +0000 Subject: [PATCH] [ssci] Add prescript to metadata validation results This CL adds a message prefix to metadata validation issues that will be presubmit errors, but are currently returned as warnings while metadata quality is still in the process of being uplifted. Bug: b:285453019 Change-Id: I2d93b7af6724f945bed3be8f1acb86fc0fddad92 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4876061 Commit-Queue: Anne Redulla Reviewed-by: Rachael Newitt --- metadata/validate.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/metadata/validate.py b/metadata/validate.py index 72a5b431a..442bd1ea9 100644 --- a/metadata/validate.py +++ b/metadata/validate.py @@ -19,6 +19,12 @@ import metadata.parse 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.\nThird party metadata issue:") + + def validate_content(content: str, source_file_dir: str, repo_root_dir: str) -> List[vr.ValidationResult]: """Validate the content as a metadata file. @@ -129,17 +135,17 @@ def check_file( error_messages = [] warning_messages = [] for result in results: - message = result.get_message(width=60) - # TODO(aredulla): Actually distinguish between validation errors # and warnings. The quality of metadata is currently being # uplifted, but is not yet guaranteed to pass validation. So for # now, all validation results will be returned as warnings so # CLs are not blocked by invalid metadata in presubmits yet. # Bug: b/285453019. - # if result.is_fatal(): - # error_messages.append(message) - # else: + if result.is_fatal(): + message = result.get_message(prescript=_TRANSITION_PRESCRIPT, + width=60) + else: + message = result.get_message(width=60) warning_messages.append(message) return error_messages, warning_messages