diff --git a/presubmit_support.py b/presubmit_support.py index 00a29a2f0..0feba2c86 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -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(), diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 9694b0c8d..1c4db0a56 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -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()