]> oss.titaniummirror.com Git - repo_shell.git/commitdiff
gitcreate: add support for default hook scripts 0.8
authorR. Steve McKown <rsmckown@gmail.com>
Sat, 21 Jun 2014 01:36:32 +0000 (19:36 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Sat, 21 Jun 2014 01:36:32 +0000 (19:36 -0600)
If the .githooks directory is present in $git_root, any scripts therein
that are relevant for a bare repository are symbolically linked into the
new repository's hook directory.

scripts/gitcreate

index 3c7cd36a447b7bee5ab0ef0207e14b88dece1650..e1363c76aca93c69cfff539b074ad4e9101ba7b0 100755 (executable)
@@ -6,7 +6,10 @@ if [ -z "$owner" -o -z "$git_root" ]; then
     echo "$0: please configure /etc/repo_shell.conf"
     exit 1
 fi
-gitacls="$git_root/.gitacls"
+gitacls=.gitacls
+gitaclspath="$git_root/$gitacls"
+githooks=.githooks
+githookspath="$git_root/$githooks"
 
 if [ "$(whoami)" != "$owner" ]; then
     echo "$0: must run as user $owner" >&2
@@ -55,7 +58,16 @@ umask 027
 git --git-dir "$git_root/$repopath" init --bare
 [ $? -ne 0 ] && exit 1
 
-[ -f "$gitacls" ] && echo "Check $gitacls for proper access permissions"
+# Create symbolic links to any hook scripts in $githookspath
+hooks="pre-receive post-receive update post-update"
+backdir=$(echo "$repopath/hooks" | sed -e 's|[^/]*|..|g')
+hookscripts=$(cd $githookspath 2>/dev/null && ls -d $hooks 2>/dev/null)
+for s in $hookscripts; do
+    echo "Linking default hook script $s"
+    ln -s $backdir/$githooks/$s $git_root/$repopath/hooks/
+done
+
+[ -f "$gitaclspath" ] && echo "Check $gitaclspath for proper access permissions"
 echo "Repository created."
-[ ! -f "$gitacls" ] && echo "WARNING: $gitacls DOES NOT EXIST!"
+[ ! -f "$gitaclspath" ] && echo "WARNING: $gitaclspath DOES NOT EXIST!"
 exit 0