From 22a80c5558391ddb4e86d61e59442f146cb3ca91 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Wed, 30 Sep 2020 08:28:48 -0500 Subject: [PATCH] Update pre-commit script to support virtual environment within IDE --- scripts/git-hooks/pre-commit | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit index 7dfa5e8aa..c704921c5 100755 --- a/scripts/git-hooks/pre-commit +++ b/scripts/git-hooks/pre-commit @@ -13,6 +13,15 @@ EXIT=0 RED='\033[0;31m' NOCOLOR='\033[0m' +if [ -d ./venv/ ]; then + VENV="$PWD/venv" + if [ -e $VENV/bin/python ]; then + PATH=$VENV/bin:$PATH + elif [ -e $VENV/Scripts/python.exe ]; then + PATH=$VENV/Scripts:$PATH + fi +fi + echo "Validating PEP8 compliance..." pycodestyle --ignore=W504,E501 netbox/ if [ $? != 0 ]; then