From: Baris Metin Date: Thu, 17 Jun 2010 16:48:29 +0000 (+0200) Subject: mirror and merge git repositories X-Git-Tag: foo~111 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=a88407b43212fc319e5a1b87cdfbec5340ac52b6;p=infrastructure.git mirror and merge git repositories --- diff --git a/scripts/git-mirror.sh b/scripts/git-mirror.sh new file mode 100644 index 0000000..434b7e8 --- /dev/null +++ b/scripts/git-mirror.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +MIRROR="git://git.planet-lab.org" +LOCAL="/git" + +function mirror () { + for arg in "$@" ; do + REPO=${arg} + REPO_NAME=${REPO}.git + MIRROR_REPO=${MIRROR}/${REPO_NAME} + LOCAL_REPO=${LOCAL}/${REPO_NAME} + + if [ -d ${REPO} ] + then + echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx pulling from ${REPO_NAME}" + pushd ${REPO} + git pull --tags + git pull + popd + else + echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mirroring in ${REPO_NAME} for the first time" + git clone ${MIRROR_REPO} + pushd ${REPO} + git remote add local_master ${LOCAL_REPO} + popd + fi + + echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx pushing ${REPO_NAME} to local master" + pushd ${REPO} + git push local_master + git push --tags local_master + popd + done +} + +args="$@" +[[ -z "$args" ]] && args=$(ls /svn) + +mirror $args +