diff options
-rw-r--r-- | share/templater/pushtodeploy/description | 1 | ||||
-rwxr-xr-x | share/templater/pushtodeploy/files/post-receive | 21 | ||||
-rwxr-xr-x | share/templater/pushtodeploy/setup | 33 |
3 files changed, 55 insertions, 0 deletions
diff --git a/share/templater/pushtodeploy/description b/share/templater/pushtodeploy/description new file mode 100644 index 0000000..79d5e8a --- /dev/null +++ b/share/templater/pushtodeploy/description @@ -0,0 +1 @@ +Git push-to-deploy strategy diff --git a/share/templater/pushtodeploy/files/post-receive b/share/templater/pushtodeploy/files/post-receive new file mode 100755 index 0000000..627198d --- /dev/null +++ b/share/templater/pushtodeploy/files/post-receive @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Post-receive git hook +# + +cd .. +unset GIT_DIR + +if [ -d ".git/annex" ]; then + git annex sync +else + git config receive.denyCurrentBranch ignore + #git reset HEAD + git checkout -f +fi + +git submodule sync --recursive +git submodule update --init --recursive + +cd - +exec git update-server-info diff --git a/share/templater/pushtodeploy/setup b/share/templater/pushtodeploy/setup new file mode 100755 index 0000000..5cd9dd1 --- /dev/null +++ b/share/templater/pushtodeploy/setup @@ -0,0 +1,33 @@ +#!/bin/bash +# +# pushtodeploy templater module. +# + +# Parameters +SHARE="$1" + +# Include basic functions +source $SHARE/templater/functions || exit 1 + +# pushtodeploy implementation +function templater_pushtodeploy { + if [ ! -e "bin/post-receive" ]; then + __templater_echo "Setting up pushtodeploy..." + + mkdir -p bin + cp $SHARE/pushtodeploy/files/post-receive bin/ + + if [ -e "Makefile" ]; then + if ! grep -q "^post_receive:" Makefile; then + echo "post_receive:" >> Makefile + echo -e "\tcd .git/hooks && ln -sf ../../bin/post-receive" >> Makefile + fi + + fi + else + __templater_echo "pushtodeploy already set" + fi +} + +# Dispatch +templater_pushtodeploy |