modified: spffq.py
[GalaxyCodeBases.git] / etc / agfw / autoproxy-gfwlist / fetch_and_merge.sh
blob29caba9deea0c84d70ccfd24f862903bfc8ec9e5
1 #!/usr/bin/env bash
3 # Fetches remote svn updates to local repository,
4 # and then merge these update into local master branch and trunk branch.
5 # Finally, push all local changes to GitHub.
7 # Exit immediately if a command exits with a non-zero status.
8 # Print commands and their arguments as they are executed.
9 set -ex
11 use_proxy=false
12 if [ "$1" = "--proxy" ]; then
13 use_proxy=true
16 if [ -z "$GFWLIST_HOME" ]; then
17 GFWLIST_HOME=/Users/zhouji/projects/autoproxy-gfwlist
20 max_retry=5
21 failure_idle=10
22 proxy_duration=120
24 function fetch_svn_updates() {
25 local i=0
26 local ret=0
27 while true; do
28 i=`expr $i + 1`
29 if $use_proxy ; then
30 proxychains4 git svn fetch
31 else
32 git svn fetch
34 ret=$?
35 if [ $ret -eq 0 ]; then
36 break
37 elif [ $i -lt $max_retry ]; then
38 sleep $failure_idle
39 else
40 break
42 done
43 return $ret
46 cd "$GFWLIST_HOME"
48 git checkout master
50 if $use_proxy ; then
51 ssh -D 7070 -f -p 22 gocalfco@gocalf.com sleep $proxy_duration
54 set +e
55 if fetch_svn_updates; then
57 else
58 exit $?
60 set -e
62 git merge origin/trunk -m 'auto merge svn trunk branch'
64 git checkout trunk
65 git merge --ff-only origin/trunk
67 git push --all
69 git checkout master