diff options
Diffstat (limited to 'create-git-hooks.sh')
-rwxr-xr-x | create-git-hooks.sh | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/create-git-hooks.sh b/create-git-hooks.sh index e2c61a6..4b779fe 100755 --- a/create-git-hooks.sh +++ b/create-git-hooks.sh @@ -1,38 +1,15 @@ #!/bin/bash -# create-git-hooks.sh -# Author: Chris Jones <cmsj@canonical.com> -# Copyright 2011 Canonical Ltd. All Rights Reserved. -OWNER="git" -GROUP="git" GITPATH="/srv/repositories/" -HOOK="exec git update-server-info" -NOUPDATE="# NO AUTOMATIC MODIFICATIONS" +GIT_TOOLS=$(readlink -f $(dirname $0)) + +umask 0022 for path in $(find -L $GITPATH -type d -name hooks) ; do HOOKFILE="${path}/post-update" - if [ ! -f $HOOKFILE ]; then - # hook file is not correct, make it correct - cat <<EOF >$HOOKFILE -#!/bin/sh -# see https://git.linaro.org/infrastructure/linaro-git-tools.git - -#-pfalcon 2013-11-14 -date >>/tmp/git-post-update.log -echo "Running git post-update hook for $GIT_DIR" >>/tmp/git-post-update.log - -exec git update-server-info -EOF - OWNERGROUP="$OWNER:$GROUP" - git --git-dir=${path}/../ --work-tree=${path}/../../ update-server-info - chown $OWNERGROUP $HOOKFILE - chmod +x $HOOKFILE - - if [ -e "${path}/../info/refs" ];then - chown $OWNERGROUP ${path}/../info/refs - fi - if [ -e "${path}/../info/objects/packs" ];then - chown $OWNERGROUP ${path}/../objects/packs - fi + if [ ! -f $HOOKFILE ] + then + # hook file does not exist, create (link) + ln -s ${GIT_TOOLS}/git-hooks/post-update $HOOKFILE fi done |