-
Notifications
You must be signed in to change notification settings - Fork 3
/
g-ship
executable file
·42 lines (40 loc) · 1.35 KB
/
g-ship
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
# g-ship
# Commit your feature branch changes back to the SVN trunk
#
# Largely inspired by Rein's "hack && ship" scripts
# http://reinh.com/blog/2008/08/27/hack-and-and-ship.html
# exit script on first error
set -e
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
if [ ${CURRENT} == "master" ]
then
echo "It is expected that this script is called from within your feature branch."
echo "Try 'git checkout branchname' first"
else
# merge out from trunk making sure we're up to date
g-update
if [ $? -eq 0 ]
then
# Total hack, as I'm too lazy to do real options parsing here
# Pass "--force" as an argument to this script to skip the running of your tests! (Shhh...)
if [ "$1" != "--force" ]
then
cd ./$(git rev-parse --show-cdup) && rake && cd -
fi
# If we ran rake above, don't continue if we have failed tests, otherwise we're just re-checking the staus of g-update
if [ $? -eq 0 ]
then
git checkout master
# I prefer to squash commits prior to committing to SVN. Feel free to omit if you feel otherwise.
git merge ${CURRENT} --squash
git commit
git svn dcommit
git branch -m ${CURRENT} DELETE-${CURRENT}
else
echo "Please fix any failing tests before shipping this feature branch."
fi
else
echo "Merging out with g-update has failed, or you do not have g-update available in your PATH."
fi
fi