#!/bin/sh

SCM_REPO_PATH=$1
SCM_TYPE=$2
SCM_PROJECT=$3

SCM_REPO_NAME=$(basename $SCM_REPO_PATH)
SCM_REPO_ROOT=$(dirname $SCM_REPO_PATH)

SVN_HOOKS=
GIT_HOOKS=
MERCURIAL_HGRC=

[ -d "$SCM_REPO_PATH" ] || exit 1

case "$SCM_TYPE" in
    svn)
        if [ -d "$SVN_HOOKS" ]; then
            mkdir -p "$SCM_REPO_PATH/hooks"
            cp -aR $SVN_HOOKS/* "$SCM_REPO_PATH/hooks"
        fi
        ;;
    git)
        if [ -d "$GIT_HOOKS" ]; then
            mkdir -p "$SCM_REPO_PATH/hooks"
            cp -aR $GIT_HOOKS/* "$SCM_REPO_PATH/hooks"
        fi
        ;;
    mercurial)
        if [ -f "$MERCURIAL_HGRC" ]; then
            mkdir -p "$SCM_REPO_PATH/.hg"
            cp "$MERCURIAL_HGRC" "$SCM_REPO_PATH/.hg/hgrc"
        fi
        ;;
    *)
        echo "SCM not supported: $SCM_TYPE" >&2
        ;;
esac

exit 0
