aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck-git-repos.py16
-rwxr-xr-xcreate-git-hooks.sh37
-rwxr-xr-xgit-hooks/post-update5
3 files changed, 24 insertions, 34 deletions
diff --git a/check-git-repos.py b/check-git-repos.py
index 4b1d975..2363bba 100755
--- a/check-git-repos.py
+++ b/check-git-repos.py
@@ -85,9 +85,16 @@ def check_ref_status(path):
log.error(out)
-def check_export_file(path):
- if not os.path.exists(os.path.join(path, EXPORT_FILE)):
- log.warn("%s not found in %s", EXPORT_FILE, path)
+def check_file_exists(filepath, islink=False, linkpath=None):
+ if not os.path.exists(filepath):
+ log.warn("%s not found", filepath)
+ else:
+ if islink:
+ if not os.path.islink(filepath):
+ log.warn("%s is not a link as expected", filepath)
+ if linkpath:
+ if os.path.realpath(filepath) != linkpath:
+ log.warn("%s does not link to %s", filepath, linkpath)
def process(paths):
@@ -95,7 +102,8 @@ def process(paths):
refsfile = os.path.join(path, "info/refs")
perms_check(refsfile)
perms_check(path+"/objects/info/packs")
- # check_export_file(path)
+ # check_file_exists(os.path.join(path, EXPORT_FILE))
+ check_file_exists(path+"/hooks/post-update", True)
check_ref_status(path)
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
diff --git a/git-hooks/post-update b/git-hooks/post-update
new file mode 100755
index 0000000..bdb960c
--- /dev/null
+++ b/git-hooks/post-update
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+umask 0022
+
+git update-server-info