awips2/tools/scripts/git-u-setup

59 lines
1.1 KiB
Text
Raw Normal View History

#!/bin/bash
#
# where am I?
#
PWD=`pwd`
#
# where is this script?
#
MY_PATH=`dirname $0`
#
# Figure out repository path
#
if [ $MY_PATH == "." ]; then
GIT_REPO_DIR=`dirname $PWD`
GIT_REPO_DIR=`dirname $GIT_REPO_DIR`
elif [ $MY_PATH == "tools/scripts" ]; then
GIT_REPO_DIR=$PWD
else
cd $MY_PATH
cd ../../
GIT_REPO_DIR=`pwd`
fi
#
# Is this a Gerrit clone?
#
grep "lightning.omaha.us.ray.com:29418" ${GIT_REPO_DIR}/.git/config >/dev/null 2>&1
if [ "$?" == "0" ]; then
GERRIT_CLONE=1
else
GERRIT_CLONE=0
fi
#
# Disclaimer / preface / continue prompt
#
echo " "
echo "This script will:"
if [ "$GERRIT_CLONE" == "1" ]; then
echo " Copy the Gerrit commit-msg (for inserting the change-id) hook to your repository hooks directory "
else
echo " Do nothing since this repository is not a Gerrit clone"
fi
echo " "
read -p "Press [Enter] key to continue (ctrl-c to quit).."
if [ "$GERRIT_CLONE" == "1" ]; then
# cp change id hook
echo "Copying Gerrit commit-msg hook to ${GIT_REPO_DIR}/.git/hooks .."
cp ${GIT_REPO_DIR}/tools/scripts/commit-msg ${GIT_REPO_DIR}/.git/hooks
else
echo "Doing nothing .."
fi