Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
try to fix the branching some more
Browse files Browse the repository at this point in the history
  • Loading branch information
ianb committed Jul 25, 2012
1 parent 76586d0 commit 7338339
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions git-sync
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -ex
set -e

if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
echo "usage: git sync [remote-name]"
Expand All @@ -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

Expand All @@ -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:"
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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.