summaryrefslogtreecommitdiff
path: root/g
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2010-11-25 00:13:14 +0100
committerNorbert Thiebaud <nthiebaud@gmail.com>2010-11-30 20:25:22 -0600
commit40dd1bc167965484486c695cc3266ab2f68f98f6 (patch)
tree10685ebf48e61e7382dabdf2f45cf15ee37d1c51 /g
parent60f200caa44ddd42830eec3a98364facba71e6e1 (diff)
git-hooks: Symlink the git hooks to the ones from git-hooks/
Diffstat (limited to 'g')
-rwxr-xr-xg23
1 files changed, 22 insertions, 1 deletions
diff --git a/g b/g
index 246d9a4066b8..05c0260fefd6 100755
--- a/g
+++ b/g
@@ -20,6 +20,19 @@ if [ ! -e ${CLONEDIR} ]; then mkdir -p $CLONEDIR; fi
RAWBUILDDIR=`perl -e 'use Cwd "abs_path"; print abs_path(shift);' $0 | sed -e ' s/\/g$//'`
if [ ! -e ${RAWBUILDDIR} ]; then mkdir -p $RAWBUILDDIR; fi
+# should we need to update the hooks
+function update_hooks()
+{
+ HOOKDIR="$1"
+ for H in `cd "$RAWBUILDDIR/git-hooks" ; echo *` ; do
+ HOOK=".git/hooks/$H"
+ if [ ! -x "$HOOK" -a ! -L "$HOOK" ] ; then
+ rm -f "$HOOK"
+ ln -s "$HOOKDIR/$H" "$HOOK"
+ fi
+ done
+}
+
# extra params for some commands, like log
EXTRA=
COMMAND="$1"
@@ -116,13 +129,17 @@ if [ "$COMMAND" = "clone" ] ; then
DIRS="artwork base calc components extensions extras filters
help impress libs-core libs-extern libs-extern-sys libs-gui
postprocess sdk testing ure writer"
+ # update hooks in the main repo too
+ ( cd "$RAWBUILDDIR" ; update_hooks "../../git-hooks" )
fi
for REPO in $DIRS ; do
DIR="$CLONEDIR/$REPO"
NAME="$REPO"
+ HOOKDIR="../../../../git-hooks"
if [ "$REPO" = "bootstrap" ] ; then
DIR="$RAWBUILDDIR"
NAME="main repo"
+ HOOKDIR="../../git-hooks"
fi
if [ \( -d "$DIR" -a -d "$DIR"/.git \) -o \( "$COMMAND" = "clone" \) ] ; then
@@ -130,6 +147,7 @@ for REPO in $DIRS ; do
# executed in a subshell
if [ "$COMMAND" != "clone" ] ; then
cd "$DIR"
+ update_hooks "$HOOKDIR"
else
cd "$CLONEDIR"
fi
@@ -202,7 +220,10 @@ for REPO in $DIRS ; do
RETURN=$?
# now we can change the dir in case of clone as well
- [ "$COMMAND" = "clone" ] && cd $DIR
+ if [ "$COMMAND" = "clone" ] ; then
+ cd $DIR
+ update_hooks "$HOOKDIR"
+ fi
# update stamp if the repo changed
NEWHEADREF=`git show-ref --head HEAD`