From 58f63c9a0246a5b1bc96906bac5d06c75237c2ca Mon Sep 17 00:00:00 2001 From: Adrian Lehmann Date: Tue, 6 Feb 2024 10:55:26 -0600 Subject: [PATCH 1/2] Fix hooks stashing issue --- .hooks/pre-commit | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.hooks/pre-commit b/.hooks/pre-commit index 7c7e212..d9d3661 100755 --- a/.hooks/pre-commit +++ b/.hooks/pre-commit @@ -4,9 +4,18 @@ BASEDIR=$(dirname "$0") # Stash changes that are not staged to check if the commited state if valid # Make sure to pop later! -git stash --keep-index -u > /dev/null 2>/dev/null +git stash --keep-index -u 2>/dev/null -"$BASEDIR/Z_X_rules_validator.py" || (echo "Error - disallowing commit: Z_X validator failed"; git stash pop > /dev/null 2>/dev/null; exit 1) -"$BASEDIR/Search_validator.py" || (echo "Error - disallowing commit: Search validator failed"; git stash pop > /dev/null 2>/dev/null; exit 1) -"$BASEDIR/Name_validator.py" || (echo "Error - disallowing commit: Naming validator failed"; git stash pop > /dev/null 2>/dev/null; exit 1) -git stash pop > /dev/null 2>/dev/null || exit 0 \ No newline at end of file +unstash() { + git stash pop > /dev/null 2>/dev/null + exit $1 +} + + +"$BASEDIR/Z_X_rules_validator.py" || { echo "Error - disallowing commit: Z_X validator failed"; unstash 1; } + +"$BASEDIR/Search_validator.py" || { echo "Error - disallowing commit: Search validator failed"; unstash 1; } + +"$BASEDIR/Name_validator.py" || { echo "Error - disallowing commit: Naming validator failed"; unstash 1; } + +unstash 0 From b2a36039578f8c8969f4b9b205cba33facbde196 Mon Sep 17 00:00:00 2001 From: Adrian Lehmann Date: Tue, 6 Feb 2024 13:46:55 -0600 Subject: [PATCH 2/2] Add python version guard --- .hooks/Name_validator.py | 9 ++++++++- .hooks/Nocheck_finder.py | 7 +++++++ .hooks/Search_validator.py | 5 +++++ .hooks/Z_X_rules_validator.py | 8 ++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.hooks/Name_validator.py b/.hooks/Name_validator.py index 9438a9f..c3c13ee 100755 --- a/.hooks/Name_validator.py +++ b/.hooks/Name_validator.py @@ -1,8 +1,15 @@ #!/usr/bin/env python3 - import re import os import sys +import sys + + +MIN_PYTHON = (3, 10) +if sys.version_info < MIN_PYTHON: + print(f"Your python version is {sys.version_info.major}.{sys.version_info.minor}. {MIN_PYTHON[0]}.{MIN_PYTHON[1]} is required") + exit(3) + args = sys.argv[1:] diff --git a/.hooks/Nocheck_finder.py b/.hooks/Nocheck_finder.py index 7674b6a..43d5c29 100755 --- a/.hooks/Nocheck_finder.py +++ b/.hooks/Nocheck_finder.py @@ -4,6 +4,13 @@ import os import sys + +MIN_PYTHON = (3, 10) +if sys.version_info < MIN_PYTHON: + print(f"Your python version is {sys.version_info.major}.{sys.version_info.minor}. {MIN_PYTHON[0]}.{MIN_PYTHON[1]} is required") + exit(3) + + b_color_yellow = '\033[93m' b_color_reset = '\033[0m' diff --git a/.hooks/Search_validator.py b/.hooks/Search_validator.py index 5065291..878c664 100755 --- a/.hooks/Search_validator.py +++ b/.hooks/Search_validator.py @@ -4,6 +4,11 @@ import os import sys +MIN_PYTHON = (3, 10) +if sys.version_info < MIN_PYTHON: + print(f"Your python version is {sys.version_info.major}.{sys.version_info.minor}. {MIN_PYTHON[0]}.{MIN_PYTHON[1]} is required") + exit(3) + args = sys.argv[1:] usage = "./Name_validator.py [--interactive]" diff --git a/.hooks/Z_X_rules_validator.py b/.hooks/Z_X_rules_validator.py index 1a00db4..d054c9d 100755 --- a/.hooks/Z_X_rules_validator.py +++ b/.hooks/Z_X_rules_validator.py @@ -2,6 +2,14 @@ import re import os +import sys + + +MIN_PYTHON = (3, 10) +if sys.version_info < MIN_PYTHON: + print(f"Your python version is {sys.version_info.major}.{sys.version_info.minor}. {MIN_PYTHON[0]}.{MIN_PYTHON[1]} is required") + exit(3) + b_color_yellow = '\033[93m' b_color_reset = '\033[0m'