diff options
author | Tzafrir Cohen <tzafrir@cohens.org.il> | 2010-06-23 12:30:22 +0300 |
---|---|---|
committer | Tzafrir Cohen <tzafrir@cohens.org.il> | 2010-06-23 12:30:22 +0300 |
commit | 078a1d45050b0e996f758e32b8eac45dbd5c6165 (patch) | |
tree | cfc5ac61358359f3e977b375b35c992f2e8de0b7 | |
parent | 401dbc8428fd5d2d85af0f75d094a6483b466e7a (diff) |
update-git-svn: script to mirror a git-svn repo
-rwxr-xr-x | update-git-svn | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/update-git-svn b/update-git-svn new file mode 100755 index 0000000..9467dd5 --- /dev/null +++ b/update-git-svn @@ -0,0 +1,46 @@ +#!/bin/sh + +# Push changes from local git-svn mirrors to gitorious repositories: +REPOS="${1:-asterisk dahdi-linux dahdi-tools libpri octapi}" +BASE_DIR=/home/git +PUSH_MIRROR=gitorious + +set -e + +# 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() { + ls .git/refs/heads/ | grep '^svn_' + ls .git/refs/tags/ | egrep '^v(|PR)[0-9]\+\.' +} + +mirror_repo() { + # Sanity check: make sure we already set up mirroring: + if ! grep -q "^\[remote \"$PUSH_MIRROR\"\]" .git/config; then + return + fi + # FIXME: make less noisy? + git push --thin --force "$PUSH_MIRROR" `mirrored_refs` +} + +# A quick snapshot of this repository. To help check if anything changed: +remotes_checksum() { + grep . .git/refs/remotes/* .git/refs/remotes/tags/* \ + | 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" ]; then + continue + fi + ../asterisk-tools/update_branches + ../asterisk-tools/update_tags + mirror_repo +done |