]> git.evergreen-ils.org Git - working/Evergreen.git/blob - build/tools/update_git_svn.sh
ac50e71fcf0d99879c6067d037460f8d544ac158
[working/Evergreen.git] / build / tools / update_git_svn.sh
1 #!/bin/bash
2 #
3 # Author: Joe Atzberger
4 #
5 # This script will update your git-svn repository from the 
6 # SVN source repo and push to a github remote (if one exists).
7 #
8 # The design is (somewhat) suitable for cronjob because it:
9 #   ~ only updates the local "master" branch
10 #   ~ dies if it cannot switch to "master"
11 #   ~ switches back to whatever branch was current initially
12 #
13 # However, it will fail if you cannot switch branches, (i.e. 
14 # have a lot of uncommited changes).  
15 #
16 # WARNING: you should NOT run this in crontab on a repo you
17 # are actively developing since switching branches (even
18 # momentarily) in the middle of editing or runtime could
19 # seriously confuse any developer.  Instead, just run it 
20 # manually as needed.
21 #
22 # Workflow might look like:
23 #   git checkout -b my_feature
24 #   [ edit, edit, edit ]
25 #   git commit -a
26 #   ./build/tools/update_git_svn.sh
27 #   git rebase master
28 #   git push github my_feature
29 #
30
31 function die_msg {
32     echo "ERROR at $1" >&2;
33     exit;
34 }
35 function parse_git_branch {
36     ref=$(git-symbolic-ref HEAD 2> /dev/null) || return;
37     ref=${ref#refs/heads/};
38     # echo "REF2: $ref";
39 }
40
41
42 parse_git_branch;
43 BRANCH=$ref;
44
45 echo "Current branch: $BRANCH";
46
47 git svn fetch  || die_msg 'git svn fetch';
48 # git status     || die_msg 'git status';
49 git checkout master  || die_msg 'git checkout master';
50
51 MESSAGE='';
52 git svn rebase  || MESSAGE="ERROR at git svn rebase;  ";
53 git checkout $BRANCH  || die_msg "${MESSAGE}git checkout $BRANCH";
54 git push github master;
55