3 MIRROR_GIT="git://git.planet-lab.org"
5 LOCAL_MIRROR_DIR="/git-mirror"
11 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $1"
16 echo "[ERROR] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $1"
23 COMMAND="$1 &> /dev/null"
30 pushd ${REPO} > /dev/null
37 arg=$(basename $arg | sed s/.git$//g)
39 NAME=$(echo ${arg} | sed 's/\/$//')
41 REPO_DIR=${LOCAL_MIRROR_DIR}/${NAME}
42 MIRROR_REPO=${MIRROR_GIT}/${GIT_NAME}
43 MASTER_REPO=${MASTER_GIT}/${GIT_NAME}
47 msg "pulling from ${REPO_NAME}"
48 run "git fetch origin --tags" ${REPO_DIR}
49 run "git fetch origin" ${REPO_DIR}
50 run "git merge --ff origin/master" ${REPO_DIR}
53 error "Can not fetch from ${MASTER_REPO}"
56 msg "mirroring in ${REPO_NAME} for the first time"
57 run "git clone ${MIRROR_REPO}" ${LOCAL_MIRROR_DIR}
58 run "git remote add local_master ${MASTER_REPO}" ${REPO_DIR}
61 msg "pushing ${REPO_NAME} to local master"
62 run "git fetch local_master --tags" ${REPO_DIR}
63 run "git fetch local_master" ${REPO_DIR}
64 run "git merge --ff local_master/master" ${REPO_DIR}
67 error "Can not fetch from ${MIRROR_REPO}"
70 run "git push local_master" ${REPO_DIR}
71 run "git push --tags local_master" ${REPO_DIR}
76 while getopts ":hq" opt
84 echo "USAGE: $0 [-q] REPONAME*"
88 echo "Invalid option: -$OPTARG" >&2