aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-11-14 10:10:10 -0200
committerSilvio Rhatto <rhatto@riseup.net>2017-11-14 10:10:10 -0200
commit494f678017709cf829da254fbd8d20fb1ace962e (patch)
treee033894e3a413de895d269c42b4ca571c134c0c3
parent92c9f801fe972548748895ac8a39c0b2eca095a1 (diff)
downloadtemplater-494f678017709cf829da254fbd8d20fb1ace962e.tar.gz
templater-494f678017709cf829da254fbd8d20fb1ace962e.tar.bz2
Adds pushtodeploy module
-rw-r--r--share/templater/pushtodeploy/description1
-rwxr-xr-xshare/templater/pushtodeploy/files/post-receive21
-rwxr-xr-xshare/templater/pushtodeploy/setup33
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