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/README.rst b/static_checks/git_hooks/README.rst
new file mode 100644
index 0000000..a1c1407
--- /dev/null
+++ b/static_checks/git_hooks/README.rst
@@ -0,0 +1,71 @@
+#########
+Git Hooks
+#########
+
+This directory is aimed at providing **code snippets** which can be inserted
+to developer's git hooks, and allow them to run the Static Check Framework
+before pushing a patch.
+
+For full description and capabilities, please refer to the official
+documentation for `Git SCM Hooks`_ .
+
+*************
+Adding a hook
+*************
+
+To use a specific hook, please manually copy the snippet to the file with
+matching name, located at
+
+.. code-block:: bash
+
+    TF-M-ROOT/.git/hooks/{HOOK_FILENAME}
+
+
+********
+Pre-Push
+********
+
+Enabling SCF requires adding the snippet on the pre-push hook. This is so that
+the check can be performed **BEFORE** a developer pushes a new patch to Gerrit
+and *ONLY IF* requested by the user.
+
+With the aim of making the functionality unintrusive, the
+following environment variables are required.
+
+- `SCF_ORG`: To set the Organisation for the purposes of Header/Copyright check.
+- `SCF_ENABLE`: To enable checking before pushing a patch.
+
+_If not set SCF_ORG defaults to 'arm'_
+
+**********************
+Custom directory paths
+**********************
+
+By default the reference code assumes the standard directory structure for
+TF-M and dependencies.
+
+.. code-block:: bash
+    └── dev-dir
+        ├── tf-m
+        ├── tf-m-tools
+
+The user can override this by setting the `TFM_ROOT_PATH`, `SCF_TEST_PATH`,
+`SCF_TEST_APP` environment variables, to match his needs.
+
+*********
+Using SCP
+*********
+
+Assuming the developer has already set-up trusted-firmware-m and tf-m-tools
+and has already copied the snippet over to `<TF-M-ROOT>/.git/hooks/pre-push`
+
+.. code-block:: bash
+
+    cd <TF-M-ROOT>
+    env SCF_ENABLE=1 git push origin HEAD:refs/for/master
+
+
+.. _Git SCM Hooks: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
+
+*Copyright (c) 2021, Arm Limited. All rights reserved.*
+*SPDX-License-Identifier: BSD-3-Clause*
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 / *******************************************