From 33dc32f7763a57452b38aa1f3df1d290a93ab767 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Mon, 24 Aug 2015 18:17:01 +0000 Subject: [PATCH] Make list-changes smarter If we can't figure out the previous version from looking in the YAML file, use git describe to find it. Show the version number being released in the header of the list-changes output so we can verify that it matches the expected value after seeing what sorts of changes are included. Change-Id: I8f65400900ee0779fd8d1736bf319e638ebbeca0 --- openstack_releases/cmds/list_changes.py | 22 +++++++++++++++------- openstack_releases/gitutils.py | 7 +++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/openstack_releases/cmds/list_changes.py b/openstack_releases/cmds/list_changes.py index 5622ef0238..8dba8011b2 100644 --- a/openstack_releases/cmds/list_changes.py +++ b/openstack_releases/cmds/list_changes.py @@ -109,12 +109,6 @@ def main(): (project['repo'], new_release['version'])) continue - if previous_release: - git_range = '%s..%s' % (previous_release['version'], - project['hash']) - else: - git_range = project['hash'] - # Check out the code. subprocess.check_call( ['zuul-cloner', @@ -125,9 +119,23 @@ def main(): ] ) + start_range = previous_release + if not start_range: + start_range = ( + gitutils.get_latest_tag(workdir, project['repo']) + or + None + ) + + if start_range: + git_range = '%s..%s' % (start_range, project['hash']) + else: + git_range = project['hash'] + # Show the changes since the last release. git_log(workdir, project['repo'], - 'Release will include', git_range) + 'Release %s will include' % new_release['version'], + git_range) # If the sha for HEAD and the requested release don't # match, show any unreleased changes on the branch. We ask diff --git a/openstack_releases/gitutils.py b/openstack_releases/gitutils.py index 12e84a2685..188a23942b 100644 --- a/openstack_releases/gitutils.py +++ b/openstack_releases/gitutils.py @@ -87,3 +87,10 @@ def check_ancestry(workdir, repo, old_version, sha): cwd=os.path.join(workdir, repo), ).strip() return bool(ancestors) + + +def get_latest_tag(workdir, repo): + return subprocess.check_output( + ['git', 'describe', '--abbrev=0'], + cwd=os.path.join(workdir, repo), + ).strip()