# gitpkg hook script to push the exported package off for building via cowpoke
#
# To enable this hook, use:
# git config gitpkg.exit-hook /usr/share/gitpkg/hooks/cowpoke-exit-hook

# We're out of the repo tree, but want to check git-config
. /usr/share/gitpkg/hooks/repo-config-helper

# See cowpoke(1) for what's valid to set in this one
while read opt; do COWPOKE_OPTS+=("$opt")
		done < <(repo_config --get-all gitpkg-cowpoke-exit-hook.options)

# Having a veto can be handy sometimes
if [ "$(repo_config --get --bool gitpkg-cowpoke-exit-hook.ask-first)" = "true" ]
then
	printf "Send $DEB_DSC off to cowpoke now (Y/n)? "
	read -e yesno
	case "$yesno" in
	    N* | n*)
		echo "Ok, you're the boss.  If you change your mind, just run:"
		echo "cowpoke ${COWPOKE_OPTS[@]} $DEB_DSC"
		echo
		exit 0
		;;
	    *) ;;
	esac
fi

echo "cowpoke ${COWPOKE_OPTS[@]} $DEB_DSC"
cowpoke "${COWPOKE_OPTS[@]}" "$DEB_DSC"

