Fix "set no parent" presubmit on Windows
While testing presubmits on Windows I hit this error:
Found the following "set noparent" restrictions in OWNERS files that do not include owners from build/OWNERS.setnoparent:
***************
sandbox\OWNERS:1
***************
And yet, in build/OWNERS.setnoparent there was a file://sandbox/OWNERS
line. The problem is simply \ versus / so this normalizes the file names
from AffectedFiles to slashes.
Changing AffectedFiles would arguably be better but is slightly
terrifying.
Bug: 1309977
Change-Id: I6d5932e3968d1c57778d8d84cd8e8d06b7e686c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3570273
Reviewed-by: Daniel Cheng <[email protected]>
Commit-Queue: Bruce Dawson <[email protected]>
Cr-Commit-Position: refs/heads/main@{#989432}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 8bd4392..4e030a55 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -3072,13 +3072,14 @@
# Check that every set noparent line has a corresponding file:// line
# listed in build/OWNERS.setnoparent. An exception is made for top level
# directories since src/OWNERS shouldn't review them.
- if (f.LocalPath().count('/') != 1
- and (not f.LocalPath() in _EXCLUDED_SET_NO_PARENT_PATHS)):
+ linux_path = f.LocalPath().replace(input_api.os_path.sep, '/')
+ if (linux_path.count('/') != 1
+ and (not linux_path in _EXCLUDED_SET_NO_PARENT_PATHS)):
for set_noparent_line in found_set_noparent_lines:
if set_noparent_line in found_owners_files:
continue
errors.append(' %s:%d' %
- (f.LocalPath(),
+ (linux_path,
found_set_noparent_lines[set_noparent_line]))
results = []