From d1ef170ff9c48b10c04e94a841290aee095eb072 Mon Sep 17 00:00:00 2001 From: Jacques GUILLOU Date: Thu, 22 Oct 2015 17:31:22 +0200 Subject: [PATCH] Support installation in submodules --- install_hooks.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/install_hooks.sh b/install_hooks.sh index dd84987..5761126 100755 --- a/install_hooks.sh +++ b/install_hooks.sh @@ -55,14 +55,19 @@ echo "" echo "Git pre-commit hook installation." echo "" if [ $# = 1 ] ; then - if [ -d "$1/.git" ] ; then + if [ -e "$1/.git" ] ; then + if [ -d "$1/.git" ] ; then + GIT_FOLDER=$1/.git + else + GIT_FOLDER=$1/`cat $1/.git | awk '{ print ($2) }'` + fi # create hooks subfolder if it does not yet exist - mkdir -p -- "$1/.git/hooks" + mkdir -p -- "$GIT_FOLDER/hooks" echo "Copying prerequisites." - cp -i -- "$SCRIPTPATH/canonicalize_filename.sh" "$1/.git/hooks/" || true + cp -i -- "$SCRIPTPATH/canonicalize_filename.sh" "$GIT_FOLDER/hooks/" || true echo "" - copy_hooks "$1/.git" + copy_hooks "$GIT_FOLDER" echo "" echo "Finished installation." else