Commit 721ff1df authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Detect release branch without Git

Existing ChromeDriver build script uses Git to determine if it is
built in a release branch. However, some distros build ChromeDriver from
source tarball, detached from Git repository (e.g., see
https://groups.google.com/a/chromium.org/forum/#!topic/chromium-packagers/LxpjcTrAzGA).
This CL updates the build script to handle such cases.

Change-Id: I9c59c90fc94dfa0bfebbbb83584ef7dda7153dc7
Reviewed-on: https://chromium-review.googlesource.com/c/1274894Reviewed-by: default avatarCaleb Rouleau <crouleau@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598860}
parent ad06ee52
......@@ -25,26 +25,35 @@ def get_release_version(chrome_version_file, version_info):
version_info: VersionInfo object returned from lastchange.FetchVersionInfo.
"""
# Release branch revision has the format
# '26c10db8bff36a8b6fc073c0f38b1e9493cabb04-refs/branch-heads/3515@{#5}'.
match = re.match('[0-9a-fA-F]+-refs/branch-heads/\d+@{#\d+}',
version_info.revision)
if not match:
# revision is not the expected format, probably not in a release branch.
return None
# Parse Chrome version file, which should have four lines of key=value,
# giving the major, minor, build, and patch number.
values = {}
version = {}
for line in open(chrome_version_file, 'r').readlines():
key, val = line.rstrip('\r\n').split('=', 1)
values[key] = val
version[key] = val
if version_info is not None:
# Release branch revision has the format
# '26c10db8bff36a8b6fc073c0f38b1e9493cabb04-refs/branch-heads/3515@{#5}'.
match = re.match('[0-9a-fA-F]+-refs/branch-heads/\d+@{#\d+}',
version_info.revision)
if not match:
# revision is not the expected format, probably not in a release branch.
return None
# Result is based on Chrome version number, e.g.,
# '70.0.3516.0 (26c10db8bff36a8b6fc073c0f38b1e9493cabb04)'.
return '%s.%s.%s.%s (%s)' % (
version['MAJOR'], version['MINOR'], version['BUILD'], version['PATCH'],
version_info.revision_id)
else:
# No version_info from Git. Assume we are in a release branch if Chrome
# patch number is not 0.
if version['PATCH'] == '0':
return None
# Result is based on Chrome version number, e.g.,
# '70.0.3516.0 (26c10db8bff36a8b6fc073c0f38b1e9493cabb04)'.
return '%s.%s.%s.%s (%s)' % (
values['MAJOR'], values['MINOR'], values['BUILD'], values['PATCH'],
version_info.revision_id)
return '%s.%s.%s.%s' % (
version['MAJOR'], version['MINOR'], version['BUILD'], version['PATCH'])
def get_master_version(chromedriver_version, version_info):
......@@ -55,6 +64,9 @@ def get_master_version(chromedriver_version, version_info):
version_info: VersionInfo object returned from lastchange.FetchVersionInfo.
"""
if version_info is None:
return None
# Master branch revision has the format
# 'cc009559c91323445dec7e2f545298bf10726eaf-refs/heads/master@{#581331}'.
# We need to grab the commit position (e.g., '581331') near the end.
......@@ -91,18 +103,18 @@ def main():
# On failure, version_info is None.
version_info = lastchange.FetchGitRevision(None, '^Change-Id:')
if version_info:
version = get_release_version(options.chrome_version_file, version_info)
version = get_release_version(options.chrome_version_file, version_info)
if not version:
version = get_master_version(chromedriver_version, version_info)
if version is None:
version = get_master_version(chromedriver_version, version_info)
if not version:
if version is None:
if version_info is not None:
# Not in a known branch, but has Git revision.
version = '%s (%s)' % (chromedriver_version, version_info.revision_id)
else:
# Git command failed for some reason. Just use ChromeDriver version string.
version = chromedriver_version
else:
# Git command failed. Just use ChromeDriver version string.
version = chromedriver_version
global_string_map = {
'kChromeDriverVersion': version
......
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