X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=usr%2Flocal%2Fbin%2Fgit-wrapper;h=e79896549d843768298bd65a591a5f6d39baedcc;hb=52519728c21edab8d3d34cb6184576dfda5157d5;hp=43da4e1d77b1086a0472bb8950f26f7d6496874f;hpb=3b28063ff56df163bced9bb9c0baf4b9b608e1eb;p=matthijs%2Fservers%2Fdrsnuggles.git diff --git a/usr/local/bin/git-wrapper b/usr/local/bin/git-wrapper index 43da4e1..e798965 100755 --- a/usr/local/bin/git-wrapper +++ b/usr/local/bin/git-wrapper @@ -9,6 +9,16 @@ # --base-path-relaxed. BASE_PATH='/data/vcs/git' +HOOKS_PATH="$BASE_PATH/hooks" +HOOKS="post-update post-receive" + +function init_repos() { + mkdir "$1" &> /dev/null || return 1 + (cd $1 && git --bare init &> /dev/null) || return 1 + for hook in $HOOKS; do + ln -s "$HOOKS_PATH/$hook" "$1/hooks/" || return 1 + done +} # We keep an array of arguments, so we can handle quoting an spaces in # arguments properly. @@ -30,7 +40,7 @@ do # When the client wants us to receive a pack, create the git # repository if it does not exist yet if [ "`basename $0`" = "git-receive-pack" -a ! -e "$DIR" ]; then - mkdir "$DIR" &> /dev/null && (cd $DIR && git --bare init &> /dev/null) + init_repos "$DIR" || exit 1 fi ARGS[$i]="$DIR" else