awips2/tools/scripts/git-u-setup
Steve Harris 77cbd6c1e5 12.9.1-5 baseline
Former-commit-id: f2fac39428 [formerly 61f269f54c [formerly d85b989f77196d20eb2d2a21cf4daa13d50474ae]]
Former-commit-id: 61f269f54c
Former-commit-id: a1d931fd44
2012-08-21 15:27:03 -05:00

118 lines
3.2 KiB
Bash

#!/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/AWIPS2_baseline" ${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 "
fi
echo " Set global git aliases in your $HOME/.gitconfig "
echo " Set filemode to false (so git will ignore file permission changes) just on this local repository"
echo " "
read -p "Press [Enter] key to continue (ctrl-c to quit).."
#
# check for mergetool and difftool
#
DIFF_TOOL=`git config --get diff.tool`
MERGE_TOOL=`git config --get merge.tool`
if [ "$MERGE_TOOL" != "" ]; then
echo "Merge tool is $MERGE_TOOL"
else
# Tool disclaimer / continue prompt
echo " "
echo "No merge tool has been set for git. A merge tool would make conflicts easier to resolve."
echo "To set a merge tool, see if you have one of the following merge tools installed:"
echo " meld opendiff kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse ecmerge p4merge araxis emerge vimdiff "
echo "And install thusly (kdiff3 used as example here): "
echo " git config --global merge.tool kdiff3"
echo " "
read -p "Press [Enter] key to continue (ctrl-c to quit).."
fi
#
# If this is a Gerrit clone - copy the change-id hook and set up Gerrit-dependent aliases
#
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
# Set up global gerrit aliases
# set the uamend alias
echo "Setting git 'uamend' alias .."
SET_ALIAS="git config --global alias.uamend !${GIT_REPO_DIR}/tools/scripts/uamend"
$SET_ALIAS
fi
#
# Set up global aliases
#
# set the upull alias
echo "Setting git 'upull' alias .."
SET_ALIAS="git config --global alias.upull !${GIT_REPO_DIR}/tools/scripts/upull"
$SET_ALIAS
# set the upush alias
echo "Setting git 'upush' alias .."
SET_ALIAS="git config --global alias.upush !${GIT_REPO_DIR}/tools/scripts/upush"
$SET_ALIAS
# set the ucommit alias
echo "Setting git 'ucommit' alias .."
SET_ALIAS="git config --global alias.ucommit !${GIT_REPO_DIR}/tools/scripts/ucommit"
$SET_ALIAS
# set the ustat alias
echo "Setting git 'ustat' alias .."
SET_ALIAS="git config --global alias.ustat !${GIT_REPO_DIR}/tools/scripts/ustat"
$SET_ALIAS
# set the pretty log alias
echo "Setting git 'plog' (pretty log) alias .."
git config --global alias.plog "log --pretty=format:'%Cgreen%ai [%h] %Cblue<%an> %Cred%s' --date-order"
# set the get alias alias
echo "Setting git 'alias' (show aliases) alias .."
git config --global alias.alias "config --get-regexp 'alias.*'"
# set filemode false
echo "Setting git filemode false .."
git config core.filemode false