From a83e6906622848185f5eb4e974ec35586dfe5043 Mon Sep 17 00:00:00 2001 From: Anne Redulla Date: Wed, 8 Nov 2023 04:01:39 +0000 Subject: [PATCH] [ssci] Add condition on license field separator warning This CL updates the License field validation so that the warning to use the standard comma separator is only returned if processing the license value resulted in multiple license types. Bug: b:309712938 Change-Id: Ic9189b8dd76e60bc3d546dea41fdb36faae8dbb4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5003558 Auto-Submit: Anne Redulla Commit-Queue: Anne Redulla Reviewed-by: Dan Le Febvre Commit-Queue: Dan Le Febvre --- metadata/fields/custom/license.py | 2 +- metadata/tests/fields_test.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/metadata/fields/custom/license.py b/metadata/fields/custom/license.py index df1a97f324..7ac4fcfb90 100644 --- a/metadata/fields/custom/license.py +++ b/metadata/fields/custom/license.py @@ -128,7 +128,7 @@ class LicenseField(field_types.MetadataField): ]) # Suggest using the standard value delimiter when possible. - if (re.search(_PATTERN_VERBOSE_DELIMITER, value) + if (len(licenses) > 1 and re.search(_PATTERN_VERBOSE_DELIMITER, value) and self.VALUE_DELIMITER not in value): return vr.ValidationWarning( reason=f"Separate licenses using a '{self.VALUE_DELIMITER}'.") diff --git a/metadata/tests/fields_test.py b/metadata/tests/fields_test.py index b491b56156..5571cff3a8 100644 --- a/metadata/tests/fields_test.py +++ b/metadata/tests/fields_test.py @@ -118,6 +118,8 @@ class FieldValidationTest(unittest.TestCase): valid_values=[ "Apache, 2.0 / MIT / MPL 2", "LGPL 2.1", + "GPL v2 or later", + "LGPL2 with the classpath exception", "Apache, Version 2 and Public domain", ], error_values=["", "\n", ",", "Apache 2.0 / MIT / "],