presubmit: fix git cl format failure in CheckPatchFormatted

CheckPatchFormatted passes the directory path of a given input file
to `git cl format` command if the directory doesn't directly contain
PRESUBMIT.py.

Now the presubmit check uses a diff file which includes a full list
of files to check the format of, and passing the directory is
no longer necessary.

Bug: 449775904
Change-Id: I50cdd58f46d058bbf5274f926578572573d814cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7018893
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
This commit is contained in:
Scott Lee
2025-10-07 15:33:12 -07:00
committed by LUCI CQ
parent 66a66dd901
commit 5269eb4445

View File

@@ -1878,12 +1878,6 @@ def CheckPatchFormatted(input_api,
input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot())
if presubmit_subdir.startswith('..') or presubmit_subdir == '.':
presubmit_subdir = ''
# If the PRESUBMIT.py is in a parent repository, then format the entire
# subrepository. Otherwise, format only the code in the directory that
# contains the PRESUBMIT.py.
if presubmit_subdir:
cmd.append(input_api.PresubmitLocalPath())
code, _ = git_cl.RunGitWithCode(cmd, suppress_stderr=bypass_warnings)
# bypass_warnings? Only fail with code 2.
# As this is just a warning, ignore all other errors if the user