From 046c1b17dfbcfef27de80c3cce37001069533432 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Tue, 6 Oct 2015 13:47:39 +0000 Subject: [PATCH] show requirements changes Add git diff output for requirements related files to show what requirements actually changed over the span of the release, if any. Change-Id: Id87c858897e75ddcee2150912d3e087743554585 --- openstack_releases/cmds/list_changes.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/openstack_releases/cmds/list_changes.py b/openstack_releases/cmds/list_changes.py index 959d6f0f0a..c2d1901541 100644 --- a/openstack_releases/cmds/list_changes.py +++ b/openstack_releases/cmds/list_changes.py @@ -19,6 +19,7 @@ from __future__ import print_function import argparse import atexit +import glob import os import os.path import shutil @@ -31,10 +32,13 @@ from openstack_releases import defaults from openstack_releases import gitutils +def header(title): + print('\n%s' % title) + print('-' * len(title)) + + def git_log(workdir, repo, title, git_range, extra_args=[]): - header = '%s %s' % (title, git_range) - print('\n%s' % header) - print('-' * len(header)) + header('%s %s' % (title, git_range)) cmd = ['git', 'log', '--no-color'] cmd.extend(extra_args) cmd.append(git_range) @@ -42,6 +46,18 @@ def git_log(workdir, repo, title, git_range, extra_args=[]): print() +def git_diff(workdir, repo, git_range, file_pattern): + repo_dir = os.path.join(workdir, repo) + files = list(glob.glob(os.path.join(repo_dir, + file_pattern))) + if files: + header('Requirements Changes %s' % git_range) + cmd = ['git', 'diff', '-U0', '--no-color', git_range] + cmd.extend(f[len(repo_dir) + 1:] for f in files) + subprocess.check_call(cmd, cwd=repo_dir) + print() + + def main(): parser = argparse.ArgumentParser() parser.add_argument( @@ -136,6 +152,9 @@ def main(): else: git_range = project['hash'] + # Show any requirements changes in the upcoming release. + git_diff(workdir, project['repo'], git_range, '*requirements*.txt') + # Show the changes since the last release, first as a # graph view so we can check for bad merges, and then with # more detail.