Skip changes that are NOPS when there are no diffs
CheckAddedDepsHaveTargetApprovals and CheckStableMojomChanges only look at lines that have changed. This makes them expensive (OldContents() is one of the most expensive presubmit functions) and guarantees that they will not find anything when run with --all or --files, when there are no changed lines. Therefore this change pragmatically returns early from these functions when no_diffs is true. This reduces "presubmit --all" times on my test machine by about 6 minutes, or 5-10%, allowing for faster iteration times. Bug: 1309977 Change-Id: I3a947efa6a59d562aa27f80fdda3f7ad38993352 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3671444 Commit-Queue: Bruce Dawson <brucedawson@chromium.org> Reviewed-by: Jesse McKenna <jessemckenna@google.com> Cr-Commit-Position: refs/heads/main@{#1010839}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
728e5b90e8
commit
344ab26d57
@ -2237,7 +2237,7 @@ def CheckAddedDepsHaveTargetApprovals(input_api, output_api):
|
||||
# We rely on Gerrit's code-owners to check approvals.
|
||||
# input_api.gerrit is always set for Chromium, but other projects
|
||||
# might not use Gerrit.
|
||||
if not input_api.gerrit:
|
||||
if not input_api.gerrit or input_api.no_diffs:
|
||||
return []
|
||||
if (input_api.change.issue and input_api.gerrit.IsOwnersOverrideApproved(
|
||||
input_api.change.issue)):
|
||||
@ -5631,7 +5631,7 @@ def CheckStableMojomChanges(input_api, output_api):
|
||||
include_deletes=True,
|
||||
file_filter=lambda f: f.LocalPath().endswith(('.mojom')))
|
||||
|
||||
if not changed_mojoms:
|
||||
if not changed_mojoms or input_api.no_diffs:
|
||||
return []
|
||||
|
||||
delta = []
|
||||
|
@ -79,6 +79,7 @@ class MockInputApi(object):
|
||||
self.change = MockChange([])
|
||||
self.presubmit_local_path = os.path.dirname(__file__)
|
||||
self.is_windows = sys.platform == 'win32'
|
||||
self.no_diffs = False
|
||||
|
||||
def CreateMockFileInPath(self, f_list):
|
||||
self.os_path.exists = lambda x: x in f_list
|
||||
|
Reference in New Issue
Block a user