#!/bin/bash

src=$(dirname $0)
src=$(cd $src;pwd)
source $src/vault-misc || exit 1

ensure_param_count_exit_usage $# 1 "<tag>"
tag=">$1"

tag_describe() {
    git describe --tags "$1" || error 33 "No tag '$1'"
}

tag=$(tag_describe "$tag")
tag_prev=$((tag_describe "$tag^" | sed -e 's|\(.*\)-[0-9]*-g[0-9a-f]*|\1|') || error 44 "No previous tag")
units=
for c in $(git log --format=%s "$tag_prev..$tag" | grep '^>'); do
    unit=$(echo $c | sed -e 's|^>||')
    if [[ "x$units" != "x" ]]; then
        units+=" $unit"
    else
        units=$unit
    fi
done
echo $units | tr " " "\n" | sort -u | grep -v "^$"

