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