Skip to content

Commit

Permalink
Add retrieve-dir hook (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartpb committed Oct 15, 2014
1 parent 68377bd commit b2ad1a9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hooks/retrieve-dir/25_git-clone
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -eo pipefail; [[ -n "$PLUSHU_TRACE" ]] && set -x

# If the directory has not yet been retrieved, and it's a Git remote
# (if we can read the repo, this will return 0, regardless of "master" status)
if [[ ! -d "$1" ]] && git ls-remote "$2" master >/dev/null 2>&1; then

# Retrieve the directory as a Git repo
git clone "$2" "$1"

# Initialize any submodules
git submodule update --init --recursive

# When installing as root, give the plushu user ownership of everything
# within the newly-cloned directory
if [[ "$EUID" == 0 ]]; then
chown -R "$PLUSHU_USER:" "$1"
fi
fi

0 comments on commit b2ad1a9

Please sign in to comment.