Print branch name when running presubmits

This implements the proposed solution B in https://crbug.com/380877175#comment5
and will help distinguish presubmit results when working with stacked changes.

Bug: 380877175
Change-Id: I7f0807f7ce03109288976069c57c28488d6cadfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6196130
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
changes/30/6196130/4
Gavin Mak 3 months ago committed by LUCI CQ
parent 8c858fc98c
commit 77a800d729

@ -1922,10 +1922,14 @@ def DoPresubmitChecks(change,
1 if presubmit checks failed or 0 otherwise.
"""
with setup_environ({'PYTHONDONTWRITEBYTECODE': '1'}):
if committing:
sys.stdout.write('Running presubmit commit checks ...\n')
else:
sys.stdout.write('Running presubmit upload checks ...\n')
running_msg = 'Running presubmit '
running_msg += 'commit ' if committing else 'upload '
running_msg += 'checks '
if branch := scm.GIT.GetBranch(change.RepositoryRoot()):
running_msg += f'on branch {branch} '
running_msg += '...\n'
sys.stdout.write(running_msg)
start_time = time_time()
presubmit_files = ListRelevantPresubmitFiles(
change.AbsoluteLocalPaths() + change.AbsoluteLocalSubmodules(),

@ -194,6 +194,7 @@ index fe3de7b..54ae6e1 100755
mock.patch('presubmit_support.warn').start()
mock.patch('random.randint').start()
mock.patch('scm.GIT.GenerateDiff').start()
mock.patch('scm.GIT.GetBranch', lambda x: None).start()
mock.patch('scm.determine_scm').start()
mock.patch('subprocess2.Popen').start()
mock.patch('sys.stderr', StringIO()).start()

Loading…
Cancel
Save