From 4dac5d6b4b39a26d72698e701e59c47278d66fec Mon Sep 17 00:00:00 2001 From: Anne Redulla Date: Tue, 19 Sep 2023 07:21:24 +0000 Subject: [PATCH] [ssci] Return relative license filepath instead of absolute This CL updates the third party metadata field License File, so that missing license filepaths are reported as relative to the repo root, instead of the absolute filepath. Bug: b:277147404 Change-Id: I16ac23d86b0ef12ab6020d8e81525965489888ac Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4876394 Auto-Submit: Anne Redulla Reviewed-by: Rachael Newitt Commit-Queue: Anne Redulla --- metadata/fields/custom/license_file.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/metadata/fields/custom/license_file.py b/metadata/fields/custom/license_file.py index a4c6d92e7b..51badfd6fc 100644 --- a/metadata/fields/custom/license_file.py +++ b/metadata/fields/custom/license_file.py @@ -110,7 +110,8 @@ class LicenseFileField(field_types.MetadataField): source_file_dir, os.path.normpath(license_filename)) if not os.path.exists(license_filepath): - invalid_values.append(license_filepath) + rel_filepath = os.path.relpath(license_filepath, repo_root_dir) + invalid_values.append(rel_filepath) if invalid_values: missing = ", ".join(invalid_values) @@ -118,7 +119,7 @@ class LicenseFileField(field_types.MetadataField): reason=f"{self._name} is invalid.", additional=[ "Failed to find all license files on local disk.", - f"Missing files:{missing}.", + f"Missing files: {missing}.", ]) return None