#!/bin/sh

## Copyright (C) 2006-2013 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## This is free software, and you are welcome to redistribute it
## under certain conditions; see COPYING for details.


set -e

_MODE="$(basename ${0} | sed -e 's|^git-||' -e 's|-retag$||')"

Tag ()
{
	_TAG="${1}"
	HASH="$(git log | grep -B4 ${_TAG} | awk '/^commit/ { print $2 }')"

	git-${_MODE}-tag ${_TAG} ${HASH}
}

for TAG in $(git tag | grep ^${_MODE})
do
	Tag $(echo ${TAG} | awk -F/ '{ print $2 }')
done
