#!/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|-release$||')"

if [ ! -e debian/changelog ]
then
	echo "E: no debian/changelog found."
	exit 1
fi

if [ -n "${1}" ]
then
	_VERSION="${1}"
else
	_VERSION="$(dpkg-parsechangelog | awk '/^Version: / { print $2 }' | cut -d: -f 2-)"
fi

_TAG="$(echo ${_VERSION} | sed -e 's|~|_|g')"

_HASH="${2}"

git add .

git commit -a -m "Releasing ${_MODE} version ${_VERSION}."
git-${_MODE}-tag ${_TAG} ${_HASH}
