#!/bin/sh # Push changes from local git-svn mirrors to gitorious repositories: BASE_DIR=/home/git PUSH_MIRROR=gitorious FORCE_UPLOAD=0 set -e while getopts 'fh' opt; do case "$opt" in f) FORCE_UPLOAD=1;; h) usage; exit 0;; \?) usage; exit 1;; esac done shift $((OPTIND-1)) REPOS="${1:-asterisk dahdi-linux dahdi-tools libpri octapi}" # An explicit list of heads to mirror. Don't push any random working branch # svn_* - branchs # v[0-9]* - tags # vPR[0-9]* - tags of octapi mirrored_refs() { { git show-ref --heads | grep 'heads/svn_' git show-ref --tags | egrep 'tags/v(|PR)[0-9]+\.' } | sed -e 's|^.*/\([^/]*\)$|\1|' } mirror_repo() { # Sanity check: make sure we already set up mirroring: if ! grep -q "^\[remote \"$PUSH_MIRROR\"\]" .git/config; then return fi git push --quiet --thin --force "$PUSH_MIRROR" `mirrored_refs` } # A quick snapshot of this repository. To help check if anything changed: remotes_checksum() { git show-ref | grep /remotes/ | sha1sum | cut -d' ' -f1 } for repo in $REPOS; do cd $BASE_DIR/$repo git checkout --quiet master sum_before=`remotes_checksum` git svn fetch --quiet --fetch-all sum_after=`remotes_checksum` if [ "$sum_before" = "$sum_after" ] && [ "$FORCE_UPLOAD" = 0 ]; then continue fi ../asterisk-tools/update_branches ../asterisk-tools/update_tags mirror_repo done