Skip to content

Commit

Permalink
Fix hooks stashing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianleh committed Feb 6, 2024
1 parent 1672944 commit 58f63c9
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions .hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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
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

0 comments on commit 58f63c9

Please sign in to comment.