SCF: Added git hooks
This patch is adding pre-push git hook to allow the
user to invoke the SCF checks before pushing a
patch to server.
Change-Id: I3cb2d3fa5e39229e9e0db7e724188f02576237a7
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
diff --git a/static_checks/git_hooks/pre-push b/static_checks/git_hooks/pre-push
new file mode 100755
index 0000000..2778e18
--- /dev/null
+++ b/static_checks/git_hooks/pre-push
@@ -0,0 +1,48 @@
+#!/bin/sh
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+#*******************************************************************************
+# SCF HOOK
+#*******************************************************************************
+
+set_default()
+{
+ if test -z "$(eval echo '$'$1)"
+ then
+ eval $1='$2'
+ fi
+}
+
+#TODO: Modify accordingly for your environment ( i.e Windows )
+set_default TFM_ROOT_PATH $(readlink -f "$(dirname $(dirname $(dirname $0)))")
+
+#TODO: Modify if tf-m-tools and tf-m are not in the same root dir, or renamed.
+set_default SCF_TEST_PATH "$TFM_ROOT_PATH/../tf-m-tools/static_checks"
+
+set_default SCF_TEST_APP "$SCF_TEST_PATH/run_all_checks.sh"
+
+
+# Use Arm as default organisation unless set by user
+if [ ! -z "$SCF_ORG" ]; then
+ echo "[SCF] Setting Organisation to: $SCF_ORG"
+else
+ SCF_ORG="arm"
+fi
+
+
+# Only run the check if SCF_ENABLE is set by user
+if [ ! -z "$SCF_ENABLE" ]; then
+ echo "[SCF] Enabling Static Check Framework"
+ eval "$SCF_TEST_APP $SCF_ORG"
+ if [ ! "$?" -eq 0 ]; then
+ echo "[SCF] Warnings Detected"
+ exit 1
+ fi
+fi
+
+#************************ SCF HOOK / *******************************************