[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 <aredulla@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
Reviewed-by: Dan Le Febvre <dlf@google.com>
Commit-Queue: Dan Le Febvre <dlf@google.com>
changes/58/5003558/2
Anne Redulla 2 years ago committed by LUCI CQ
parent 197399a8ac
commit a83e690662

@ -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}'.")

@ -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 / "],

Loading…
Cancel
Save