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
This commit is contained in:
Doug Hellmann 2015-10-06 13:47:39 +00:00
parent 624513d667
commit 046c1b17df

View File

@ -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.