From 7c17f7b88694f1edbbff13bf261077d3057a62df Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Thu, 30 Apr 2015 21:07:10 +0000 Subject: [PATCH] Add list_unreleased_changes.sh Add a script to list the changes in a given branch of a set of repositories. Change-Id: I3ed3df4fb640f20d9d86eb0a9618fbb67a58be77 --- .gitignore | 1 + README.rst | 19 ++++++++++ functions | 23 ++++++++++++ list_unreleased_changes.sh | 74 ++++++++++++++++++++++++++++++++++++++ release_library.sh | 14 +------- 5 files changed, 118 insertions(+), 13 deletions(-) create mode 100755 list_unreleased_changes.sh diff --git a/.gitignore b/.gitignore index 00460da..a57bc2a 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ ChangeLog # local temporary directory release-tag-* +list-unreleased-* diff --git a/README.rst b/README.rst index 638bec0..6737b8a 100644 --- a/README.rst +++ b/README.rst @@ -176,6 +176,25 @@ Examples: is useful for examining the list of unreleased changes in a project to decide if a release is warranted and to pick a version number. +list_unreleased_changes.sh +-------------------------- + +Given a branch and one or more repositories, produce a list of the +changes in those repositories since their last tag on that +branch. This is useful for deciding if a project needs to prepare a +release, and for predicting what the next release version should be by +looking at the commit logs. + +./list_unreleased_changes.sh master openstack/oslo.config + + Print the list of changes in ``openstack/oslo.config`` along the + master branch. + +./list_unreleased_changes.sh stable/kilo $(./list_repos_by_project.py --code-only Oslo) + + Print the list of changes in the ``stable/kilo`` branch of all Oslo + libraries. + make_library_stable_branch.sh ----------------------------- diff --git a/functions b/functions index 0a4985a..ff2c61d 100644 --- a/functions +++ b/functions @@ -14,3 +14,26 @@ function lp_project_to_repo { echo $proj | sed -e 's|python-||' fi } + +function title { + echo + echo "$(tput bold)$(tput setaf 1)[ $1 ]$(tput sgr0)" +} + + +function _cleanup_tmp { + title "Cleaning up" + rm -rf $MYTMPDIR +} + + +function setup_temp_space { + MYTMPDIR=`mktemp -d ${1}-XXX` + mkdir -p "$MYTMPDIR" + trap _cleanup_tmp EXIT + cd "$MYTMPDIR" + # NOTE(dhellmann): On some platforms mktemp returns a short name + # instead of a full path, so expand the full path by looking at + # where we ended up after the cd operation. + MYTMPDIR="$(pwd)" +} diff --git a/list_unreleased_changes.sh b/list_unreleased_changes.sh new file mode 100755 index 0000000..8e63e7c --- /dev/null +++ b/list_unreleased_changes.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Provide a list of the unreleased changes in the given repositories + +bindir=$(cd $(dirname $0) && pwd) +branch="$1" +shift +repos="$@" + +source $bindir/functions + +# Make sure no pager is configured so the output is not blocked +export PAGER= + +function get_last_tag { + # Use git log to show changes on this branch, and add --decorate + # to include the tag names. Then use grep and sed to pull the tag + # name out so that is all we pass to highest_semver.py. + # + # This assumes the local copy of the repo is on the branch from + # which we would want to release. + git log --decorate --oneline \ + | egrep '^[0-9a-f]+ \((HEAD, )?tag: ' \ + | sed -r 's/^.+tag: ([^ ]+)[,\)].+$/\1/g' \ + | ${bindir}/highest_semver.py + + # Look at *all* tags, sorted by the date they were applied. This + # sometimes predicts the wrong value, especially when we might be + # releasing from a branch other than master. + # + # git for-each-ref --sort=taggerdate --format '%(refname)' refs/tags \ + # | sed -e 's|refs/tags/||' \ + # | ${bindir}/highest_semver.py +} + +setup_temp_space 'list-unreleased' + +function list_changes { + git clone -q git://git.openstack.org/$repo -b $branch + if [[ $? -ne 0 ]]; then + return 1 + fi + cd $(basename $repo) + prev_tag=$(get_last_tag) + if [ -z "$prev_tag" ]; then + echo "$repo has not yet been released" + else + echo + $bindir/release_notes.py \ + --show-dates \ + --changes-only \ + . $prev_tag HEAD + fi +} + +# Show the unreleased changes for each repository. +for repo in $repos; do + cd $MYTMPDIR + echo + title "$repo" + list_changes "$repo" +done diff --git a/release_library.sh b/release_library.sh index 8180996..555a103 100755 --- a/release_library.sh +++ b/release_library.sh @@ -43,24 +43,12 @@ PROJECT=$4 TOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -function title { - echo - echo "$(tput bold)$(tput setaf 1)[ $1 ]$(tput sgr0)" -} - if [[ $VERSION == *a* ]]; then ALPHA_RELEASE=1 TARGET="next-$SERIES" fi -MYTMPDIR=`mktemp -d release-tag-$PROJECT-XXX` -function cleanup_tmp { - title "Cleaning up" - cd /tmp - rm -rf $MYTMPDIR -} -trap cleanup_tmp EXIT -cd $MYTMPDIR +setup_temp_space release-tag-$PROJECT REPO=$(lp_project_to_repo $PROJECT)