Flake8 Git Pre-Commit Hook

From crowdresearch
Revision as of 06:25, 22 January 2016 by Shirishgoyal (Talk | contribs) (Created page with "From your project's root directory, create a new file .git/hooks/pre-commit Add below code to it. Remember to update VIRTUAL_ENV with path for virtualenv (normally it is $H...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

From your project's root directory, create a new file .git/hooks/pre-commit

Add below code to it. Remember to update VIRTUAL_ENV with path for virtualenv (normally it is $HOME/.virtualenvs/<environ-name>)

   #!/bin/bash
   export VIRTUAL_ENV=~/.virtualenvs/crowd
   if [ -n $VIRTUAL_ENV ]; then
       PATH=$VIRTUAL_ENV/bin:$PATH
   fi
   for f in .git/hooks/pre-commit.d/*; do
       if [ -x "$f" ]; then
           if ! "$f"; then
               echo "COMMIT FAILED!";
               exit 1
           fi
       fi
   done
   unset VIRTUAL_ENV