#!/bin/bash

cwd=`/bin/pwd`
me=`whoami`
stripped=${cwd#/home/$me/repos/}

if [ $stripped = $cwd ]
then
	stripped=${cwd#/mounted/repos/}
fi

if [ $stripped = $cwd ]
then
	echo "Can't get repo name from ${cwd} aborting"
	exit 0
fi

FRONTENDS=$(dig mercurial-uwsgi-headless.default.svc.cluster.local +short)
for fe in $FRONTENDS
do
	hg push http://${fe}:8080/${stripped}
done

exit 0
