Gitリポジトリのミラーリングを行っているだけの場合は、cronジョブを設定して次のスクリプトを実行できます。
#!/bin/bash
USER=bitbucketuser
ERROR_FILE=clone_update_err
CLONES=/path/to/clones
cd $CLONES
if [ $# -ne 1 ]; then
for DIR in *; do
if [ -d $DIR ]; then
./update.sh $DIR 2> $ERROR_FILE
if [ -s $ERROR_FILE ]; then
echo $DIR >&2
cat -n $ERROR_FILE >&2
fi
fi
done
else
DIR=$1
echo $DIR
cd $DIR
if [ -a source ]; then
cd source
if [ -d .hg ]; then
hg pull
elif [ -d .git ]; then
git pull
elif [ -d .bzr ]; then
bzr pull
elif [ -d .svn ]; then
svn up
else
echo "$DIR is not a known repository type."
return 1
fi
cd ..
hg convert source hg
URL=ssh://hg@bitbucket.org/$USER/$DIR/
cd hg
hg pull $URL
hg push $URL # You can add -f here if you don't mind multiple heads
cd ..
else
# hg dir or hg-git
cd hg
hg pull
hg push $URL
cd ..
fi
cd ..
sleep 5
fi
これは、SSHキーがインストールされていることを前提としています。ご覧のとおり、他のVCSもミラーリングされます。次のようなディレクトリ構造を想定しています。
clones/
project1/
source/ # Original Git/Bazaar/SVN/Mercurial repo
hg/ # Mercurial repo
明らかに、これは一方向にすぎませんが、Gitですべての作業を行う場合は、問題にはなりません。