@@ -209,14 +209,15 @@ setup() {
209209 local ref=` config_get ref`
210210 local fetch=` config_get fetch`
211211 local branch=${ref#*/ }
212+
212213 hook_pre_setup || abort pre-setup hook failed
213214 run " mkdir -p $path /{shared/{logs,pids},source}"
214215 test $? -eq 0 || abort setup paths failed
215216 log running setup
216217 log cloning $repo
217- if test fetch ! = " fast" ; then
218+ if test $ fetch ! = " fast" ; then
218219 log " full fetch"
219- run " git clone $repo $path /source"
220+ run " git clone --branch $branch $repo $path /source"
220221 else
221222 log " fast fetch"
222223 run " git clone --depth=5 --branch $branch $repo $path /source"
@@ -234,6 +235,10 @@ setup() {
234235
235236deploy () {
236237 local ref=$1
238+ local branch=$2
239+ if test -z " $branch " ; then
240+ branch=${ref#*/ }
241+ fi
237242 local path=` config_get path`
238243 local fetch=` config_get fetch`
239244
@@ -249,7 +254,7 @@ deploy() {
249254 # fetch source
250255 log fetching updates
251256
252- if test fetch ! = " fast" ; then
257+ if test $ fetch ! = " fast" ; then
253258 log " full fetch"
254259 run " cd $path /source && git fetch --all --tags"
255260 else
@@ -269,10 +274,10 @@ deploy() {
269274 test $? -eq 0 || abort failed to determine latest tag
270275 fi
271276
272- # reset HEAD
273- log resetting HEAD to $ref
274- run " cd $path /source && git reset --hard $ref "
275- test $? -eq 0 || abort git reset failed
277+ # checkout ref to branch
278+ log checkout $ref to $branch
279+ run " cd $path /source && git checkout $ref -b $branch "
280+ test $? -eq 0 || abort git checkout failed
276281
277282 # link current
278283 run " ln -sfn $path /source $path /current"
@@ -384,11 +389,11 @@ while test $# -ne 0; do
384389 setup) setup $@ ; exit ;;
385390 list) list_deploys; exit ;;
386391 config) config $@ ; exit ;;
387- ref) REF=$1 ;;
392+ ref) REF=$1 ; BRANCH= $2 ;;
388393 esac
389394done
390395
391396check_for_local_changes
392397
393398# deploy
394- deploy " ${REF:- `config_get ref`} "
399+ deploy " ${REF:- `config_get ref`} " " ${BRANCH} "
0 commit comments