From 5801032f1bcbe6c84e7183a64ab4e1bfe56839c6 Mon Sep 17 00:00:00 2001 From: atz Date: Tue, 22 Jun 2010 22:07:06 +0000 Subject: [PATCH] Script for git-svn repos (with possible github remote) Please heed WARNING in the script comments. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16784 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- build/tools/update_git_svn.sh | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 build/tools/update_git_svn.sh diff --git a/build/tools/update_git_svn.sh b/build/tools/update_git_svn.sh new file mode 100755 index 0000000000..ac50e71fcf --- /dev/null +++ b/build/tools/update_git_svn.sh @@ -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; + -- 2.43.2