Kaydet (Commit) 71e52007 authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

use translations' own hooks. update the hooks after the clone/fetch/pull

üst 76c1ec0c
......@@ -17,30 +17,83 @@ if [ "$#" -eq "0" ] ; then
exit $?
fi
CLONEDIR=$(perl -e 'use Cwd "abs_path"; print abs_path(shift);' $0 | sed -e ' s/\/g$/\/clone/')
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()
pushd $(dirname $0) > /dev/null
COREDIR=$(pwd)
popd > /dev/null
refresh_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
repo=$1
case "$repo" in
core)
pushd $COREDIR > /dev/null
for hook_name in $(ls -1 $COREDIR/git-hooks) ; do
hook=".git/hooks/$hook_name"
if [ ! -x "$hook" -a ! -L "$hook" ] ; then
rm -f "$hook"
ln -s "git-hooks/$hook_name" "$hook"
fi
done
popd > /dev/null
;;
translations)
if [ -d $COREDIR/clone/translations ] ; then
pushd $COREDIR/clone/translations > /dev/null
for hook_name in $(ls -1 $COREDIR/clone/translations/git-hooks) ; do
hook=".git/hooks/$hook_name"
rm -f "$hook"
ln -sf "git-hooks/$hook_name" "$hook"
done
# .gitattribute should be per-repo, avoid entangling repos
if [ -L .gitattributes ] ; then
rm -f .gitattributes
fi
popd > /dev/null
fi
;;
help|dictionaries)
if [ -d $COREDIR/clone/$core ] ; then
pushd $COREDIR/clone/$core > /dev/null
# fixme: we should really keep these per-repo to
# keep the repos independant. since these two
# are realy not independant yet, we keep using core's hooks
for hook_name in $(ls -1 $COREDIR/git-hooks) ; do
hook=".git/hooks/$hook_name"
rm -f "$hook"
ln -sf "$COREDIR/git-hooks/$hook_name" "$hook"
done
# .gitattribute should be per-repo, avoid entangling repos
if [ -L .gitattributes ] ; then
rm -f .gitattributes
fi
popd > /dev/null
fi
;;
esac
}
refresh_all_hooks()
{
repos="core $(cat "$COREDIR/bin/repo-list")"
for repo in $repos ; do
refresh_hooks $repo
done
if [ -z "$(git config push.default)" ] ; then
git config push.default tracking
fi
if [ "$PWD" != "$RAWBUILDDIR" -a ! -e .gitattributes ]; then
ln -s $RAWBUILDDIR/.gitattributes .
}
postprocess()
{
rc=$1
if $DO_HOOK_REFRESH ; then
refresh_all_hooks
fi
exit $rc;
}
CLONEDIR="$COREDIR/clone"
if [ ! -e ${CLONEDIR} ]; then mkdir -p "$CLONEDIR"; fi
# extra params for some commands, like log
EXTRA=
COMMAND="$1"
......@@ -51,6 +104,7 @@ ALLOW_EMPTY=
KEEP_GOING=0
REPORT_REPOS=1
REPORT_COMPACT=0
DO_HOOK_REFRESH=false
while [ "${COMMAND:0:1}" = "-" ] ; do
case "$COMMAND" in
......@@ -74,6 +128,9 @@ case "$COMMAND" in
EXTRA="-p0 --stat --apply --index --ignore-space-change --whitespace=error"
RELATIVIZE=0
;;
clone|fetch|pull)
DO_HOOK_REFRESH=true
;;
diff)
PAGER='--no-pager'
REPORT_REPOS=0
......@@ -147,18 +204,14 @@ done
# do it!
DIRS="core $(cd $CLONEDIR ; ls)"
if [ "$COMMAND" = "clone" ] ; then
DIRS=$(cat "$RAWBUILDDIR/bin/repo-list")
# update hooks in the main repo too
( cd "$RAWBUILDDIR" ; update_hooks "../../git-hooks" )
DIRS=$(cat "$COREDIR/bin/repo-list")
fi
for REPO in $DIRS ; do
DIR="$CLONEDIR/$REPO"
NAME="$REPO"
HOOKDIR="../../../../git-hooks"
if [ "$REPO" = "core" ] ; then
DIR="$RAWBUILDDIR"
DIR="$COREDIR"
NAME="main repo"
HOOKDIR="../../git-hooks"
fi
if [ -d "$DIR" -a "z$PUSH_USER" != "z" ]; then
......@@ -169,7 +222,6 @@ for REPO in $DIRS ; do
# executed in a subshell
if [ "$COMMAND" != "clone" ] ; then
cd "$DIR"
update_hooks "$HOOKDIR"
else
cd "$CLONEDIR"
fi
......@@ -248,21 +300,20 @@ for REPO in $DIRS ; do
# now we can change the dir in case of clone as well
if [ "$COMMAND" = "clone" ] ; then
cd $DIR
update_hooks "$HOOKDIR"
fi
case "$COMMAND" in
pull|clone)
# update links
if [ "$DIR" != "$RAWBUILDDIR" ]; then
if [ "$DIR" != "$COREDIR" ]; then
for link in $(ls) ; do
if [ ! -e "$RAWBUILDDIR/$link" ] ; then
if test -h "$RAWBUILDDIR/$link"; then
rm "$RAWBUILDDIR/$link"
if [ ! -e "$COREDIR/$link" ] ; then
if test -h "$COREDIR/$link"; then
rm "$COREDIR/$link"
echo -n "re-"
fi
echo "creating missing link $link"
ln -s "$DIR/$link" "$RAWBUILDDIR/$link"
ln -s "$DIR/$link" "$COREDIR/$link"
fi
done
fi
......@@ -282,16 +333,16 @@ for REPO in $DIRS ; do
fi
exit $RETURN
) || exit $?
) || postprocess $?
fi
done
# Cleanup the broken links
if [ "$COMMAND" = "pull" ] ; then
for link in $(ls $RAWBUILDDIR) ; do
if [ -h "$RAWBUILDDIR/$link" -a ! -e "$RAWBUILDDIR/$link" ]; then
for link in $(ls $COREDIR) ; do
if [ -h "$COREDIR/$link" -a ! -e "$COREDIR/$link" ]; then
echo "Removing broken link $link"
rm $RAWBUILDDIR/$link
rm $COREDIR/$link
fi
done
fi
......@@ -303,4 +354,6 @@ if [ "$COMMAND" = "apply" ] ; then
echo
fi
postprocess $?
# vi:set shiftwidth=4 expandtab:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment