#!/bin/bash
#============================================================================#
#    Simple utility for git-amend with update commit comment from specfile   #
#============================================================================#
. /usr/bin/gear-sh-functions
. shell-getopt

if [ "x$1" != "x" ]; then
	vr="$(sed -ne '/^[[:space:]]*%changelog[[:space:]]*$/{n; s/\* .* \([^[:space:]]\+\)$/\1/p}' "$1")"
	ch="$(sed -ne '0,/^[[:space:]]*%changelog[[:space:]]*$/d;2,/^* /{/^* /!p}' "$1")"
	T=`mktemp`
	echo $vr > $T
	echo "$ch" >> $T
	git commit -a --amend -F $T
	rm -f $T
else
	git commit -a --amend
fi

