Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Account for tracking branches when hacking/shipping.

  • Loading branch information...
commit 78eb418249de73eb271cee43721ef7e848527014 1 parent f491c58
Brian Donovan authored
Showing with 43 additions and 14 deletions.
  1. +21 −7 bin/hack
  2. +22 −7 bin/ship
View
28 bin/hack
@@ -53,8 +53,22 @@ if [[ "$explain" == true ]]; then
echo "These are the commands that would be run:"
fi
-if [[ "$CURRENT" != "master" ]]; then
- git checkout master
+REMOTE=`$GIT config branch.$CURRENT.remote`
+
+if [[ -z "$REMOTE" ]]; then
+ REMOTE=origin
+fi
+
+TRACK=`$GIT config branch.$CURRENT.merge`
+
+if [[ -z "$TRACK" ]]; then
+ TRACK=refs/heads/master
+fi
+
+TRACK_BRANCH=${TRACK/refs\/heads\//}
+
+if [[ "$CURRENT" != "$TRACK_BRANCH" ]]; then
+ git checkout $TRACK_BRANCH
fi
$GIT svn info >/dev/null 2>/dev/null
@@ -67,11 +81,11 @@ fi
if [[ "$TYPE" == "git-svn" ]]; then
git svn rebase
else
- git fetch origin
- git rebase origin/master
+ git fetch $REMOTE
+ git rebase $REMOTE/$TRACK_BRANCH
fi
-if [[ "$CURRENT" != "master" ]]; then
- git checkout ${CURRENT}
- git rebase master
+if [[ "$CURRENT" != "$TRACK_BRANCH" ]]; then
+ git checkout $CURRENT
+ git rebase $TRACK_BRANCH
fi
View
29 bin/ship
@@ -5,7 +5,6 @@ CURRENT=`git branch | grep "\*" | cut -d' ' -f2`
explaining=false
verbose=true
run=true
-remote=origin
printUsage() {
echo "usage: $0 [options] [remote]"
@@ -43,7 +42,7 @@ for arg in "$@"; do
exit 1
;;
*)
- remote=$arg
+ REMOTE=$arg
esac
done
@@ -58,8 +57,24 @@ if [[ "$explain" == true ]]; then
echo "These are the commands that would be run:"
fi
-if [[ "$CURRENT" != "master" ]]; then
- git checkout master
+if [[ -z "$REMOTE" ]]; then
+ REMOTE=`$GIT config branch.$CURRENT.remote`
+fi
+
+if [[ -z "$REMOTE" ]]; then
+ REMOTE=origin
+fi
+
+TRACK=`$GIT config branch.$CURRENT.merge`
+
+if [[ -z "$TRACK" ]]; then
+ TRACK=refs/heads/master
+fi
+
+TRACK_BRANCH=${TRACK/refs\/heads\//}
+
+if [[ "$CURRENT" != "$TRACK_BRANCH" ]]; then
+ git checkout $TRACK_BRANCH
fi
$GIT svn info >/dev/null 2>/dev/null
@@ -73,13 +88,13 @@ if [[ "$TYPE" == "git-svn" ]]; then
git rebase ${CURRENT}
git svn dcommit
else
- if [[ "$CURRENT" != "master" ]]; then
+ if [[ "$CURRENT" != "$TRACK_BRANCH" ]]; then
git merge ${CURRENT}
fi
- git push ${remote} master
+ git push ${REMOTE} ${TRACK_BRANCH}
fi
-if [[ "$CURRENT" != "master" ]]; then
+if [[ "$CURRENT" != "$TRACK_BRANCH" ]]; then
git checkout ${CURRENT}
fi
Please sign in to comment.
Something went wrong with that request. Please try again.