aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Hart <matthew.hart@linaro.org>2015-08-20 11:57:54 +0100
committerLinaro Code Review <review@review.linaro.org>2015-08-24 11:31:43 +0000
commitaab0f9260c3bdbada2788e7d765073067412798e (patch)
tree21985789f2fcb7092d79fe3085b0104e6a194f79
parentfc81f9403da5a6df1d869c6118ade1fea07a0141 (diff)
downloadlinaro-git-tools-aab0f9260c3bdbada2788e7d765073067412798e.tar.gz
create a common post-update git hook
create-git-hooks.sh: instead of creating a post-update hook, symlink to the common one which forces the correct umask. Also no longer perform any chmod/chown as this should no longer be needed and complicates the permissions issues we are seeing. check-git-repos.py: Check that the hooks/post-update file exists Change-Id: I531c15960f71c839f3aa3c8bf0e0a08b8fb5c580
-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