Fix version calculation for older commits on a release branch (fixes issue #2659)
This commit is contained in:
parent
c7701b8a61
commit
f9b042c375
|
@ -172,11 +172,18 @@ class VersionFormatter:
|
||||||
cef_commit = self.get_cef_commit_components()
|
cef_commit = self.get_cef_commit_components()
|
||||||
cef_commit_hash = self._format_commit_hash(cef_commit['HASH'])
|
cef_commit_hash = self._format_commit_hash(cef_commit['HASH'])
|
||||||
|
|
||||||
# Remove the remote name prefix, if any.
|
# Determine whether the current commit is on a release branch. For example,
|
||||||
cef_branch_name = git.get_branch_name(self.cef_path).split('/')[-1]
|
# if using Chrome build 3683, are we on CEF branch "3683" or "origin/3683"?
|
||||||
|
release_branch = chrome_version['BUILD']
|
||||||
|
on_release_branch = (
|
||||||
|
git.is_ancestor(self.cef_path, 'HEAD', release_branch) or
|
||||||
|
git.is_ancestor(self.cef_path, 'HEAD', 'origin/' + release_branch))
|
||||||
|
|
||||||
|
if not on_release_branch:
|
||||||
|
# Not on a commit that is part of an official named release branch. See
|
||||||
|
# if we can get the name of the branch we are on (may be just "HEAD").
|
||||||
|
cef_branch_name = git.get_branch_name(self.cef_path).split('/')[-1]
|
||||||
|
|
||||||
if cef_branch_name != chrome_version['BUILD']:
|
|
||||||
# Not on an official named release branch.
|
|
||||||
self._version_parts = {'MAJOR': int(chrome_major), 'MINOR': 0, 'PATCH': 0}
|
self._version_parts = {'MAJOR': int(chrome_major), 'MINOR': 0, 'PATCH': 0}
|
||||||
self._version_string = '%s.0.0-%s.%s+%s+%s' % \
|
self._version_string = '%s.0.0-%s.%s+%s+%s' % \
|
||||||
(chrome_major, cef_branch_name, cef_commit['NUMBER'],
|
(chrome_major, cef_branch_name, cef_commit['NUMBER'],
|
||||||
|
|
|
@ -10,6 +10,7 @@ def exec_cmd(cmd, path, input_string=None):
|
||||||
""" Execute the specified command and return the result. """
|
""" Execute the specified command and return the result. """
|
||||||
out = ''
|
out = ''
|
||||||
err = ''
|
err = ''
|
||||||
|
ret = -1
|
||||||
parts = cmd.split()
|
parts = cmd.split()
|
||||||
try:
|
try:
|
||||||
if input_string is None:
|
if input_string is None:
|
||||||
|
@ -20,6 +21,7 @@ def exec_cmd(cmd, path, input_string=None):
|
||||||
stderr=PIPE,
|
stderr=PIPE,
|
||||||
shell=(sys.platform == 'win32'))
|
shell=(sys.platform == 'win32'))
|
||||||
out, err = process.communicate()
|
out, err = process.communicate()
|
||||||
|
ret = process.returncode
|
||||||
else:
|
else:
|
||||||
process = Popen(
|
process = Popen(
|
||||||
parts,
|
parts,
|
||||||
|
@ -29,8 +31,9 @@ def exec_cmd(cmd, path, input_string=None):
|
||||||
stderr=PIPE,
|
stderr=PIPE,
|
||||||
shell=(sys.platform == 'win32'))
|
shell=(sys.platform == 'win32'))
|
||||||
out, err = process.communicate(input=input_string)
|
out, err = process.communicate(input=input_string)
|
||||||
|
ret = process.returncode
|
||||||
except IOError, (errno, strerror):
|
except IOError, (errno, strerror):
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
return {'out': out, 'err': err}
|
return {'out': out, 'err': err, 'ret': ret}
|
||||||
|
|
|
@ -18,6 +18,13 @@ def is_checkout(path):
|
||||||
return os.path.isdir(os.path.join(path, '.git'))
|
return os.path.isdir(os.path.join(path, '.git'))
|
||||||
|
|
||||||
|
|
||||||
|
def is_ancestor(path='.', commit1='HEAD', commit2='master'):
|
||||||
|
""" Returns whether |commit1| is an ancestor of |commit2|. """
|
||||||
|
cmd = "%s merge-base --is-ancestor %s %s" % (git_exe, commit1, commit2)
|
||||||
|
result = exec_cmd(cmd, path)
|
||||||
|
return result['ret'] == 0
|
||||||
|
|
||||||
|
|
||||||
def get_hash(path='.', branch='HEAD'):
|
def get_hash(path='.', branch='HEAD'):
|
||||||
""" Returns the git hash for the specified branch/tag/hash. """
|
""" Returns the git hash for the specified branch/tag/hash. """
|
||||||
cmd = "%s rev-parse %s" % (git_exe, branch)
|
cmd = "%s rev-parse %s" % (git_exe, branch)
|
||||||
|
|
Loading…
Reference in New Issue