From 7338339d494ffa3246b9f44bb2859c0838fab868 Mon Sep 17 00:00:00 2001 From: Ian Bicking Date: Wed, 25 Jul 2012 15:35:49 -0500 Subject: [PATCH] try to fix the branching some more --- git-sync | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/git-sync b/git-sync index e145bdb..e21f3e0 100755 --- a/git-sync +++ b/git-sync @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -ex +set -e if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then echo "usage: git sync [remote-name]" @@ -13,7 +13,7 @@ if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then echo " $ git config --add sync.default.repo .remote-repo" echo " $ git config --add sync.default.remote git@hostname:/path.git" echo "And optionally:" - echo " $ git config --add sync.default.branch master" + echo " $ git config --add sync.default.branch gh-pages" exit fi @@ -32,9 +32,9 @@ if [ -z "$repo_location" ] ; then repo_location="${repo_location}/$(basename $(pwd))" fi +remote_branch="$(git config --get sync.${dest}.branch || true)" if [ ! -e $repo_location ] ; then remote="$(git config --get sync.${dest}.remote || true)" - remote_branch="$(git config --get sync.${dest}.branch || true)" if [ -z "$remote" ] ; then echo "You must set sync.${dest}.remote" echo "Like:" @@ -50,12 +50,19 @@ if [ ! -e $repo_location ] ; then fi echo "making git repo in $repo_location$git_msg" mkdir -p "$(basename $repo_location)" + echo git clone $git_op $remote $repo_location git clone $git_op $remote $repo_location else # pull from master to ensure we're uptodate ( cd $repo_location - git pull origin master:master + if [ -z "$remote_branch" ] ; then + git_op="" + else + git_op="$remote_branch:$remote_branch" + fi + echo cd $repo_location "&&" git pull origin $git_op + git pull origin $git_op ) fi @@ -67,7 +74,7 @@ fi ## FIXME: should I exclude untracked files? Seems like it # per discussion over build tools issue, rsync everything -rsync --recursive --delete --exclude .git . $repo_location +rsync --recursive --delete --exclude .git --exclude $repo_location . $repo_location if [ -e .syncignore ] ; then cat .syncignore >> $repo_location/.gitignore @@ -90,5 +97,11 @@ version="$(git describe --always --dirty)" git add $adds fi git commit -a -m "deployment $version" - git push origin master + if [ -z "$remote_branch" ] ; then + git_op="" + else + git_op="$remote_branch:$remote_branch" + fi + echo cd $repo_location "&&" git push origin $git_op + git push origin $git_op )