forked from openstreetmap/openstreetmap-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjosm-mirror.sh
39 lines (33 loc) · 1.36 KB
/
josm-mirror.sh
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
#!/bin/bash -e
# Changes already pulled, merge them to the mirror branch
git branch mirror || :
git checkout mirror
git merge master
# Just do a plain copy of the externals into this repository. Get the
# current list with a "svn checkout" and:
#
# svn propget svn:externals -R
#
# The format is sort of bizarre and inconsistent, but these two
# regexes seem to capture the external we need to clone.
#
# The reason for doing the removal here is that if something gets
# removed from the export we won't remove those files unless we nuke
# the whole directory and re-export it. This still isn't perfect, if
# the externals list changes to remove an external we won't remove it,
# but hopefully that doesn't happen that often..
tmpexternals=$(mktemp .git/josm-mirror.sh-XXXXX)
git svn show-externals | grep ^/ | perl -pe 's[^/([^ ]+) (http[^ \n]+)$][svn export --force $2 $1]m; s[^/([^ ]+?)/(http[^ ]+) ([^ ]+)$][svn export --force $2 $1/$3]' >$tmpexternals
rm -rfv $(awk '{print $5}' $tmpexternals)
. $tmpexternals
rm -v $tmpexternals
# Commit externals changes, if any
git config user.name "JOSM GitHub mirror"
git config user.email "[email protected]"
git add .
git commit -m"josm-mirror: bumped externals" || :
# Push the mirror to GitHub
git remote add mirror [email protected]:openstreetmap/josm.git || :
# Push to our mirrors
git push -v mirror master
git push -v mirror mirror