From a3a014e9d5f0a1dc0a17f39aaf5f93c962e696f1 Mon Sep 17 00:00:00 2001 From: Bruce Dawson Date: Wed, 27 Apr 2022 23:28:17 +0000 Subject: [PATCH] Handle mixed slash types in FilterSourceFile The files_to_skip lists in chrome/android/java/src/PRESUBMIT.py were not working on Windows because they didn't use the verbose [\\\/] construct for path separators. Fixing this in FilterSourceFile means that multiple failures may be fixed simultaneously. The only failures that this is known to fix are a set of AlertDialog.Builder errors that were showing up only on Windows. This addresses the issues that were going to be incorrectly fixed in crrev.com/c/3606128 (now abandoned). Bug: 1309977 Change-Id: I7a10483448e00df55e2cbf8bff8bad7a5d8db124 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3609117 Reviewed-by: Robbie Iannucci Commit-Queue: Bruce Dawson --- presubmit_support.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/presubmit_support.py b/presubmit_support.py index 3e963ec28..5ff2a236e 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -773,6 +773,11 @@ class InputApi(object): for item in items: if self.re.match(item, local_path): return True + # Handle the cases where the files regex only handles /, but the local + # path uses \. + if self.is_windows and self.re.match(item, local_path.replace( + '\\', '/')): + return True return False return (Find(affected_file, files_to_check) and not Find(affected_file, files_to_skip))