R
R
raiboon2015-05-25 14:29:15
Python
raiboon, 2015-05-25 14:29:15

How to set up git-precommit hooks for a python project?

I can't figure out why it doesn't work.
I took sample, renamed it to pre-commit, left the standard ones.
Added below:

echo hahaha
touched_python_files=`git diff --cached --name-only |egrep '\.py$' || true`

autopep8 -v \
        --in-place \
        --aggressive \
        $touched_python_files


nosetests
code=$?

if [ "$code" == "0" ]; then
exit 0
fi

echo -n "Not all tests pass. Commit (y/n): "
read response
if [ "$response" == "y" ]; then
exit 0
fi

exit $code

git-pylint-commit-hook

echo hahaha - running
autopep8 and nose - not running, they just work from the terminal. Why is that?
git-pylint-commit-hook (hence - https://github.com/sebdah/git-pylint-commit-hook ) doesn't work at all, neither from the hook nor just in the terminal. Does anyone use? Can you tell me how easy it is to use pylint here?
Can you help figure out what's wrong?
And what else interesting do you have in pre-commit hooks?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Shandrinov, 2015-05-25
@suguby

I can assume that there is an environment for the project and it is not activated...
(pylint is paranoid! it's hard to work with it every day, once every six months for the sake of interest - it's normal)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question