safely handle git clone from alien directory

git clone can experience permission errors if called from a
cwd which is not the parent of the target for the clone.

This is hard to replicate, but seems to have something to
do with the underlying user executing puppet not being 'stack'
(e.g. 'vagrant').

When the user is 'stack' the cwd is probably /home/stack anyway.

In any case, this fixes it.
This commit is contained in:
Chris Dent
2014-05-29 11:10:06 +01:00
parent 3a04738765
commit 1a20a28119

View File

@@ -46,6 +46,9 @@ function git_clone {
local GIT_DEST=$2
local GIT_REF=$3
# Avoid git exiting when in some other dir than the typical /home/stack
cd $(dirname $GIT_DEST)
# do a full clone only if the directory doesn't exist
if [[ ! -d $GIT_DEST ]]; then
git_timed clone $GIT_REMOTE $GIT_DEST