Permalink
Browse files

try to fix the branching some more

  • Loading branch information...
1 parent 76586d0 commit 7338339d494ffa3246b9f44bb2859c0838fab868 @ianb committed Jul 25, 2012
Showing with 19 additions and 6 deletions.
  1. +19 −6 git-sync
View
@@ -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
)

0 comments on commit 7338339

Please sign in to comment.