new_release: use sha from corresponding stable branches

Before the fix, sha values were always extracted from master head, even
when series has a stable branch.

Change-Id: I9810660df7a92c021cd9c154bb3f24d8d828bfd7
This commit is contained in:
Ihar Hrachyshka
2016-03-23 20:05:31 +01:00
parent 29651876b5
commit 64b3319dc9
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

@@ -113,3 +113,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 []