[open-ils-commits] r16784 - trunk/build/tools (atz)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Jun 22 18:07:12 EDT 2010


Author: atz
Date: 2010-06-22 18:07:06 -0400 (Tue, 22 Jun 2010)
New Revision: 16784

Added:
   trunk/build/tools/update_git_svn.sh
Log:
Script for git-svn repos (with possible github remote)

Please heed WARNING in the script comments.

Added: trunk/build/tools/update_git_svn.sh
===================================================================
--- trunk/build/tools/update_git_svn.sh	                        (rev 0)
+++ trunk/build/tools/update_git_svn.sh	2010-06-22 22:07:06 UTC (rev 16784)
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# Author: Joe Atzberger
+#
+# This script will update your git-svn repository from the 
+# SVN source repo and push to a github remote (if one exists).
+#
+# The design is (somewhat) suitable for cronjob because it:
+#   ~ only updates the local "master" branch
+#   ~ dies if it cannot switch to "master"
+#   ~ switches back to whatever branch was current initially
+#
+# However, it will fail if you cannot switch branches, (i.e. 
+# have a lot of uncommited changes).  
+#
+# WARNING: you should NOT run this in crontab on a repo you
+# are actively developing since switching branches (even
+# momentarily) in the middle of editing or runtime could
+# seriously confuse any developer.  Instead, just run it 
+# manually as needed.
+#
+# Workflow might look like:
+#   git checkout -b my_feature
+#   [ edit, edit, edit ]
+#   git commit -a
+#   ./build/tools/update_git_svn.sh
+#   git rebase master
+#   git push github my_feature
+#
+
+function die_msg {
+    echo "ERROR at $1" >&2;
+    exit;
+}
+function parse_git_branch {
+    ref=$(git-symbolic-ref HEAD 2> /dev/null) || return;
+    ref=${ref#refs/heads/};
+    # echo "REF2: $ref";
+}
+
+
+parse_git_branch;
+BRANCH=$ref;
+
+echo "Current branch: $BRANCH";
+
+git svn fetch  || die_msg 'git svn fetch';
+# git status     || die_msg 'git status';
+git checkout master  || die_msg 'git checkout master';
+
+MESSAGE='';
+git svn rebase  || MESSAGE="ERROR at git svn rebase;  ";
+git checkout $BRANCH  || die_msg "${MESSAGE}git checkout $BRANCH";
+git push github master;
+


Property changes on: trunk/build/tools/update_git_svn.sh
___________________________________________________________________
Name: svn:executable
   + *



More information about the open-ils-commits mailing list