From a776f5198f03dd99431d2cabbfa86edf0201520c Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Mon, 15 Mar 2021 20:41:34 +0100 Subject: [PATCH] Avoid two consecutive version updates. No-Presubmit: True Bug: webrtc:12159 Change-Id: Iad9e4f1e6b971241cb8ddce8e36f1b8e8d8a39f8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212021 Commit-Queue: Mirko Bonadei Reviewed-by: Philipp Hancke Cr-Commit-Position: refs/heads/master@{#33474} --- tools_webrtc/version_updater/update_version.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools_webrtc/version_updater/update_version.py b/tools_webrtc/version_updater/update_version.py index d5a72b8710..3c2be3fe75 100644 --- a/tools_webrtc/version_updater/update_version.py +++ b/tools_webrtc/version_updater/update_version.py @@ -42,6 +42,14 @@ def _RemovePreviousUpdateBranch(): logging.info('No branch to remove') +def _GetLastAuthor(): + """Returns a string with the author of the last commit.""" + author = subprocess.check_output(['git', 'log', + '-1', + '--pretty=format:"%an"']).splitlines() + return author + + def _GetBranches(): """Returns a tuple (active, branches). @@ -142,11 +150,15 @@ def main(): if opts.clean: _RemovePreviousUpdateBranch() + if _GetLastAuthor() == 'webrtc-version-updater': + logging.info('Last commit is a version change, skipping CL.') + return 0 + version_filename = os.path.join(CHECKOUT_SRC_DIR, 'call', 'version.cc') _CreateUpdateBranch() _UpdateWebRTCVersion(version_filename) if _IsTreeClean(): - logging.info("No WebRTC version change detected, skipping CL.") + logging.info('No WebRTC version change detected, skipping CL.') else: _LocalCommit() logging.info('Uploading CL...')