Merge branch 'master' of git.onelab.eu:/git/infrastructure
authorBaris Metin <Talip-Baris.Metin@sophia.inria.fr>
Thu, 17 Jun 2010 16:48:36 +0000 (18:48 +0200)
committerBaris Metin <Talip-Baris.Metin@sophia.inria.fr>
Thu, 17 Jun 2010 16:48:36 +0000 (18:48 +0200)
scripts/git-mirror.sh [new file with mode: 0644]

diff --git a/scripts/git-mirror.sh b/scripts/git-mirror.sh
new file mode 100644 (file)
index 0000000..434b7e8
--- /dev/null
@@ -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
+