From c341d58921ab188e4edacce04a221559bce86e8d Mon Sep 17 00:00:00 2001 From: Joanna Wang Date: Mon, 22 Jan 2024 16:47:55 +0000 Subject: [PATCH] Include submodules when looking for PRESUBMIT files. Bug: 1475770 Change-Id: I3a4b10a8dc68db9f0507bb3cefa62d233df53b68 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5219691 Reviewed-by: Scott Lee Auto-Submit: Joanna Wang Commit-Queue: Scott Lee --- presubmit_support.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/presubmit_support.py b/presubmit_support.py index e0117bb88..25970f173 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -1349,10 +1349,18 @@ class Change(object): """Convenience function.""" return [af.LocalPath() for af in self.AffectedFiles()] + def LocalSubmodules(self): + """Returns local paths for affected submodules.""" + return [af.LocalPath() for af in self.AffectedSubmodules()] + def AbsoluteLocalPaths(self): """Convenience function.""" return [af.AbsoluteLocalPath() for af in self.AffectedFiles()] + def AbsoluteLocalSubmodules(self): + """Returns absolute local paths for affected submodules""" + return [af.AbsoluteLocalPath() for af in self.AffectedSubmodules()] + def RightHandSideLines(self): """An iterator over all text lines in 'new' version of changed files. @@ -1521,8 +1529,8 @@ def DoPostUploadExecuter(change, gerrit_obj, verbose): """ python_version = 'Python %s' % sys.version_info.major sys.stdout.write('Running %s post upload checks ...\n' % python_version) - presubmit_files = ListRelevantPresubmitFiles(change.LocalPaths(), - change.RepositoryRoot()) + presubmit_files = ListRelevantPresubmitFiles( + change.LocalPaths() + change.LocalSubmodules(), change.RepositoryRoot()) if not presubmit_files and verbose: sys.stdout.write('Warning, no PRESUBMIT.py found.\n') results = [] @@ -1824,7 +1832,8 @@ def DoPresubmitChecks(change, python_version) start_time = time_time() presubmit_files = ListRelevantPresubmitFiles( - change.AbsoluteLocalPaths(), change.RepositoryRoot()) + change.AbsoluteLocalPaths() + change.AbsoluteLocalSubmodules(), + change.RepositoryRoot()) if not presubmit_files and verbose: sys.stdout.write('Warning, no PRESUBMIT.py found.\n') results = []