From c5ec9fc69721adfd2344371afe67b48a5cacd5ff Mon Sep 17 00:00:00 2001
From: Frederik Hennig <frederik.hennig@fau.de>
Date: Fri, 1 Dec 2023 08:50:30 +0100
Subject: [PATCH] added git hooks

---
 git-hooks/pre-commit | 20 ++++++++++++++++++++
 install_git_hooks.sh |  5 +++++
 2 files changed, 25 insertions(+)
 create mode 100755 git-hooks/pre-commit
 create mode 100644 install_git_hooks.sh

diff --git a/git-hooks/pre-commit b/git-hooks/pre-commit
new file mode 100755
index 0000000..9016685
--- /dev/null
+++ b/git-hooks/pre-commit
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+echo "[Pre-Commit] Checking code style"
+pdm run flake8 src/pystencilssfg
+status=$?
+
+if [ ${status} != 0 ]; then
+    exit 1
+else
+    echo "[Pre-Commit] Style OK!"
+fi
+
+echo "[Pre-Commit] Checking types"
+pdm run mypy src/pystencilssfg
+status=$?
+if [ ${status} != 0 ]; then
+    exit 1
+else
+    echo "[Pre-Commit] Types OK!"
+fi
diff --git a/install_git_hooks.sh b/install_git_hooks.sh
new file mode 100644
index 0000000..eeb1b61
--- /dev/null
+++ b/install_git_hooks.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cp git-hooks/pre-commit .git/hooks/pre-commit
+chmod +x .git/hooks/pre-commit
+
-- 
GitLab