#!/bin/sh

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

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

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

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

RPNAME=$(get_gear_name)

# FIXME: если не нашли, стоит взять название каталога за основу
[ -n "$RPNAME" ] || fatal "Can't detect project name. Run inside git repo."

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