3 MIRROR_GIT="git://git.planet-lab.org"
5 LOCAL_MIRROR_DIR="/git-mirror"
11 echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $1"
16 echo "[ERROR] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx $1"
22 COMMAND="$1 &> /dev/null"
29 pushd ${REPO} > /dev/null
36 NAME=$(basename ${arg} | sed s/.git$//g)
38 REPO_DIR=${LOCAL_MIRROR_DIR}/${NAME}
39 MIRROR_REPO=${MIRROR_GIT}/${GIT_NAME}
40 MASTER_REPO=${MASTER_GIT}/${GIT_NAME}
44 msg "pulling from ${REPO_NAME}"
45 run "git fetch origin --tags" ${REPO_DIR}
46 run "git fetch origin" ${REPO_DIR}
47 run "git merge --ff origin/master" ${REPO_DIR}
50 error "Can not fetch from ${MASTER_REPO}"
53 msg "mirroring in ${REPO_NAME} for the first time"
54 run "git clone ${MIRROR_REPO}" ${LOCAL_MIRROR_DIR}
55 run "git remote add local_master ${MASTER_REPO}" ${REPO_DIR}
58 msg "pushing ${REPO_NAME} to local master"
59 run "git fetch local_master --tags" ${REPO_DIR}
60 run "git fetch local_master" ${REPO_DIR}
61 run "git merge --ff local_master/master" ${REPO_DIR}
64 error "Can not fetch from ${MIRROR_REPO}"
66 run "git push local_master" ${REPO_DIR}
67 run "git push --tags local_master" ${REPO_DIR}
73 while getopts ":hq" opt
81 echo "USAGE: $0 [-q] REPONAME*"
85 echo "Invalid option: -$OPTARG" >&2