summaryrefslogtreecommitdiff
path: root/update-git-svn
blob: 9467dd547fa357692fb38fc10e692d6883fb55ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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