#!/bin/bash

_project_=bobcat
_product_=bobcat

echo if any modified or untracked files are shown, they MUST be handled first:
echo
git st
echo -n "Continue [Yn] ? "
read yesno
[ "$yesno" == "y" -o "$yesno" == "" ]   ||   exit 0

git co master

cd ${_product_}
./build man

./build gitlab
./build distclean
cd ..    
git co web-pages

cp -r ../wip/changelog.txt ../wip/manhtml .

echo
echo -n "Check index.yo: version and last 5 releases [y/n] ? "
read yesno

if [ "$yesno" == "y" ] ; then
    cat ../wip/release.yo
    emacs index.yo
fi

yodl2html index.yo || exit 1


echo "Running 'git st': check for unexpected files"
git st

echo

echo -n "ci change to index.html etc., push the result and co master [y/n] ? "
read yesno

if [ "$yesno" == "y" ] ; then

    RELEASE=`head -n1 ../wip/release.yo | 
                sed 's/SUBST(_CurVers_)(\(.*\))/\1/'`

    msgDefault="web-pages for release ${RELEASE}"

    echo -n "Enter the ci message [default: $msgDefault]"

    read msg;

    [ "$msg" == "" ] && msg=$msgDefault

    git ci -am "$msg"
    git push
    git co master
fi

