Commit 94d0c0e6 authored by Aleksey Khoroshilov's avatar Aleksey Khoroshilov Committed by LUCI CQ

Pass upstream branch to git cl format --dry-run (if set).

When PRESUBMIT is run with a custom --upstream, dry run cl format should
also use this value, otherwise format warnings would be inconsistent.

Change-Id: I1370f614618ecc03706e54cd4b151a207d9b3bae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3688631
Auto-Submit: Aleksey Khoroshilov <akhoroshilov@brave.com>
Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
parent 04663d61
......@@ -1505,6 +1505,11 @@ def CheckPatchFormatted(input_api,
cmd = ['-C', input_api.change.RepositoryRoot(),
'cl', 'format', '--dry-run', '--presubmit'] + display_args
# Make sure the passed --upstream branch is applied to a dry run.
if input_api.change.UpstreamBranch():
cmd.extend(['--upstream', input_api.change.UpstreamBranch()])
presubmit_subdir = input_api.os_path.relpath(
input_api.PresubmitLocalPath(), input_api.change.RepositoryRoot())
if presubmit_subdir.startswith('..') or presubmit_subdir == '.':
......@@ -1514,6 +1519,7 @@ def CheckPatchFormatted(input_api,
# 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment