X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=scripts%2Fgit-mirror.sh;h=3f05125dfb8410fc4e0ba803ef78e58b953b08c2;hb=a8aa1baef6f4d1df60f44d1d542912acff913226;hp=3ff06f58ec612567e76c5556409d48e466259128;hpb=2b6079112ea32c7fdcb4cba4ff604909335ba103;p=infrastructure.git diff --git a/scripts/git-mirror.sh b/scripts/git-mirror.sh index 3ff06f5..3f05125 100755 --- a/scripts/git-mirror.sh +++ b/scripts/git-mirror.sh @@ -2,7 +2,7 @@ COMMAND=$(basename $0) # for sending emails (-a option) -ADMINS="Thierry.Parmentelat@inria.fr baris@metin.org" +ADMINS="Thierry.Parmentelat@inria.fr" # the other end of the mirror (-r option) REMOTE_GIT="git://git.planet-lab.org" # options @@ -105,10 +105,11 @@ function merge_all_branches () { pushd $REPO_DIR > /dev/null BRANCHES=$(git branch -r | grep $REMOTE | grep -v HEAD | sed "s/.*\///g" | grep -v master) + HAS_MASTER=$(git branch -l | grep master) popd > /dev/null - run ${REPO_DIR} git checkout master - run ${REPO_DIR} git merge --ff $REMOTE/master + [ -n "$HAS_MASTER" ] && run ${REPO_DIR} git checkout master + [ -n "$HAS_MASTER" ] && run ${REPO_DIR} git merge --ff $REMOTE/master for BRANCH in $BRANCHES ; do run -i ${REPO_DIR} git branch $BRANCH $REMOTE/$BRANCH run ${REPO_DIR} git checkout $BRANCH @@ -124,9 +125,10 @@ function push_all_branches () { pushd $REPO_DIR > /dev/null BRANCHES=$(git branch -r | grep $PUSH_FROM | grep -v HEAD | sed "s/.*\///g" | grep -v master) + HAS_MASTER=$(git branch -l | grep master) popd > /dev/null - run ${REPO_DIR} git push $PUSH_TO master:master + [ -n "$HAS_MASTER" ] && run ${REPO_DIR} git push $PUSH_TO master:master for BRANCH in $BRANCHES ; do run ${REPO_DIR} git push $PUSH_TO $BRANCH:$BRANCH done @@ -142,6 +144,13 @@ function mirror_repo () { REMOTE_REPO=${REMOTE_GIT}/${GIT_NAME} MASTER_REPO=${MASTER_GIT}/${GIT_NAME} + # if the local master is a symlink (like /git/vserver-reference.git -> sliceref.git) + # then skip it + # we use this for either aliases (like vserver-reference and sliceimage) or + # for repos managed in other locations (like /git-slave) but where + # the symlink is needed so they get served by git-daemon + [ -h ${MASTER_REPO} ] && return + # if there is no remote repository it may be that we only have # the repository locally and don't need to mirror git ls-remote $REMOTE_REPO &> /dev/null || return @@ -189,6 +198,8 @@ function mirror_repo () { fi # success, remove previous check file if any clear_notify $REPO_DIR + # touch a stamp so it's easier to figure out where/if things get stuck + touch ${REPO_DIR}/MIRRORED.stamp } function usage () { @@ -202,7 +213,7 @@ function usage () { exit 1 } -while getopts "a:r:qvfh" opt; do +while getopts "a:r:s:qvfh" opt; do case $opt in a) ADMINS=$OPTARG ;; r) REMOTE_GIT=$OPTARG ;;