From 01e56e37d1c7d9f41055a46010e8b7c6ac62ec9a Mon Sep 17 00:00:00 2001
From: lukken <lukken@astron.nl>
Date: Tue, 28 Sep 2021 12:18:00 +0000
Subject: [PATCH] L2SS-393: Use alias in lofar20rc.sh to install githooks

---
 bin/update_submodules.sh   | 2 ++
 bootstrap/etc/lofar20rc.sh | 4 ++++
 2 files changed, 6 insertions(+)
 create mode 100755 bin/update_submodules.sh

diff --git a/bin/update_submodules.sh b/bin/update_submodules.sh
new file mode 100755
index 000000000..9dcb97458
--- /dev/null
+++ b/bin/update_submodules.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+git submodule update --init
diff --git a/bootstrap/etc/lofar20rc.sh b/bootstrap/etc/lofar20rc.sh
index e9e8ac326..dd26d6df0 100755
--- a/bootstrap/etc/lofar20rc.sh
+++ b/bootstrap/etc/lofar20rc.sh
@@ -12,6 +12,10 @@
 ABSOLUTE_PATH=$(realpath $(dirname ${BASH_SOURCE}))
 export LOFAR20_DIR=${1:-$(realpath ${ABSOLUTE_PATH}/../..)}
 
+if [ ! -f "${LOFAR20_DIR}/.git/hooks/post-checkout" ]; then
+  alias git="cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-checkout; cp ${LOFAR20_DIR}/bin/update_submodules.sh ${LOFAR20_DIR}/.git/hooks/post-merge; unalias git; git"
+fi
+
 # This needs to be modified for a development environment.
 # Example:  ~/lofar2.0/tango
 # The current setting is for a production environment.
-- 
GitLab