]> gitweb.fluxo.info Git - templater.git/commitdiff
Adds pushtodeploy module
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 14 Nov 2017 12:10:10 +0000 (10:10 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 14 Nov 2017 12:10:10 +0000 (10:10 -0200)
share/templater/pushtodeploy/description [new file with mode: 0644]
share/templater/pushtodeploy/files/post-receive [new file with mode: 0755]
share/templater/pushtodeploy/setup [new file with mode: 0755]

diff --git a/share/templater/pushtodeploy/description b/share/templater/pushtodeploy/description
new file mode 100644 (file)
index 0000000..79d5e8a
--- /dev/null
@@ -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 (executable)
index 0000000..627198d
--- /dev/null
@@ -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 (executable)
index 0000000..5cd9dd1
--- /dev/null
@@ -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