Move get_last_tag to functions

Move the shell function for retrieving the last tag in a repository into
the functions file where we can share it.

Change-Id: Ia06b7954d7ec0e0cfe27e3529402cd03473dd53f
This commit is contained in:
Doug Hellmann 2015-05-01 18:02:06 +00:00
parent 14c89ba2d9
commit 98e45f9cd2
2 changed files with 26 additions and 24 deletions

View File

@ -37,3 +37,26 @@ function setup_temp_space {
# where we ended up after the cd operation.
MYTMPDIR="$(pwd)"
}
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' \
| ${TOOLSDIR}/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/||' \
# | ${TOOLSDIR}/highest_semver.py
}

View File

@ -14,37 +14,16 @@
#
# Provide a list of the unreleased changes in the given repositories
bindir=$(cd $(dirname $0) && pwd)
branch="$1"
shift
repos="$@"
source $bindir/functions
TOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $TOOLSDIR/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 {
@ -58,7 +37,7 @@ function list_changes {
echo "$repo has not yet been released"
else
echo
$bindir/release_notes.py \
$TOOLSDIR/release_notes.py \
--show-dates \
--changes-only \
. $prev_tag HEAD