#!/bin/sh

# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
load_mod git

test -r "$1" && fatal "Do not need any files in params"

if [ "$1" = "-h" ] ; then
	echo "ginit - initialize repo in $GIRARHOST for current project"
	echo "Use: ginit [GIRAR]"
	echo "     ginit git.eter - for init in git.eter gear repo"
	exit 1
fi

if is_girar_name $1 ; then
	GIRARHOST=$1
	shift
fi

PROJECTNAME=$(get_gear_name)

echo "Create remote $PROJECTNAME repo in $GIRARHOST:"
ssh $GIRARHOST git-init-db $PROJECTNAME.git
echo "Create $GIRARHOST remote repo alias"
git remote add $GIRARHOST $GIRARHOST:packages/$PROJECTNAME.git
