Merge "new_release: use sha from corresponding stable branches"

This commit is contained in:
Jenkins 2016-05-16 15:19:46 +00:00 committed by Gerrit Code Review
commit a435e4aae3
2 changed files with 25 additions and 1 deletions

View File

@ -104,7 +104,14 @@ def main():
projects = []
for project in last_release['projects']:
gitutils.clone_repo(workdir, project['repo'])
sha = gitutils.sha_for_tag(workdir, project['repo'], 'HEAD')
branches = gitutils.get_branches(workdir, project['repo'])
version = 'origin/stable/%s' % series
if not any(branch for branch in branches
if branch.endswith(version)):
version = 'master'
sha = gitutils.sha_for_tag(workdir, project['repo'], version)
projects.append({
'repo': project['repo'],
'hash': sha,

View File

@ -116,3 +116,20 @@ def get_latest_tag(workdir, repo):
print('WARNING failed to retrieve latest tag: %s [%s]' %
(e, e.output.strip()))
return None
def get_branches(workdir, repo):
try:
output = subprocess.check_output(
['git', 'branch', '-a'],
cwd=os.path.join(workdir, repo),
stderr=subprocess.STDOUT,
).strip()
return [
branch
for branch in output.split()
]
except subprocess.CalledProcessError as e:
print('ERROR failed to retrieve list of branches: %s [%s]' %
(e, e.output.strip()))
return []