[3575] | 1 | if [ "$GITSVNLMDZ" != "true" ];then |
---|
| 2 | export GITSVNLMDZ=true |
---|
| 3 | else |
---|
| 4 | exit 0 |
---|
| 5 | fi |
---|
| 6 | RED='\033[0;31m' |
---|
| 7 | NC='\033[0m' # No Color |
---|
| 8 | |
---|
| 9 | # check if on master |
---|
| 10 | local_branch=$(git branch --show-current) |
---|
| 11 | ROOT_DIR=$( git rev-parse --show-toplevel ) |
---|
| 12 | |
---|
| 13 | echo Branch: $local_branch |
---|
| 14 | |
---|
| 15 | echo done |
---|
| 16 | if [ "${local_branch}" != "master" ]; then |
---|
| 17 | exit 0 # if on other branch than master, do not sync with svn |
---|
| 18 | fi |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | ### check if git svn exists |
---|
| 22 | git svn info>/dev/null 2>&1 |
---|
| 23 | GITSVN=$? |
---|
| 24 | if [ $GITSVN != 0 ] |
---|
| 25 | then |
---|
| 26 | printf "${RED}You need to install git svn to use this script.${NC}\n" |
---|
| 27 | exit $GITSVN |
---|
| 28 | fi |
---|
| 29 | |
---|
| 30 | if [ ! -f ${ROOT_DIR}/.git/refs/remotes/git-svn ];then |
---|
| 31 | git svn init https://svn.lmd.jussieu.fr/Planeto/trunk |
---|
| 32 | git update-ref refs/remotes/git-svn refs/remotes/origin/master # this could fail if git is not up-to-date with svn... |
---|
| 33 | fi |
---|
| 34 | |
---|
| 35 | # git update-ref refs/remotes/git-svn refs/remotes/origin/master # tell git-svn it's up-to-date with git remote master branch |
---|
| 36 | |
---|
| 37 | HEAD=$(git rev-list master|head -n 1) |
---|
| 38 | CUR=$(git rev-list master | wc -l) |
---|
| 39 | echo "Before svn rebase, master had $CUR commits" |
---|
| 40 | |
---|
| 41 | ### get changes from svn |
---|
| 42 | git svn rebase |
---|
| 43 | REBASED=$? |
---|
| 44 | if [ $REBASED != 0 ] # check if rebase worked |
---|
| 45 | then |
---|
| 46 | echo "${RED}git svn rebase failed.${NC}\n" |
---|
| 47 | exit $REBASED |
---|
| 48 | fi |
---|
| 49 | POST=$(git rev-list master | wc -l) |
---|
| 50 | echo "After svn rebase, master has $POST commits" |
---|
| 51 | echo "Object counts were $CUR::$POST" |
---|
| 52 | |
---|
| 53 | echo "git svn rebase worked." |
---|
| 54 | if [ ! $CUR = $POST ] # check if there were changes from svn |
---|
| 55 | then |
---|
| 56 | echo "${RED}You will need to push now.${NC}" |
---|
| 57 | fi |
---|
| 58 | |
---|