From 94d0c0e624f613c424d2500116200b6114e8d06b Mon Sep 17 00:00:00 2001 From: Aleksey Khoroshilov Date: Fri, 3 Jun 2022 17:30:15 +0000 Subject: [PATCH] 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 Reviewed-by: Josip Sokcevic Commit-Queue: Josip Sokcevic --- presubmit_canned_checks.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 5131d74cb..30ec436f5 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -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