R
R
raiboon2015-02-05 17:07:28
Django
raiboon, 2015-02-05 17:07:28

How to implement a pre-commit code check mechanism?

Django project. Repository on bitbucket. There is jenkins - it is used only for deploying by nodes.
I've known for a long time. but never used hooks in gita. Is it possible to implement validation with pylint, pyflake (and maybe later for js-html-css), run tests so that it would not be possible to commit until you satisfy them?
Unfortunately, the level of discipline in the team is too low, which I cannot influence. We need a way to fix the code faster than cutting down or bypassing checks.
UPD.
Thanks Stanislav Fateevfor the naive implementation, but... It's too easy to manage, we had it at the beginning of a new project, but a large number of "sorry, it was necessary to fix it very urgently, and not look at the checks" - turned most of the tests and the quality of the code into nothing. I wanted to discuss whether it is possible to make a system based on, for example, jenkins and bitbucket hooks ... Or other approaches that are not recommended, but made to "behave well".

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Fateev, 2015-02-05
@svfat

Create .git/hooks/pre-commit with content

python manage.py test
exit $?

"exit$?" will return an error code, and if it is non-zero, the commit will fail.
Of course, you can add pylint, pyflake, and add something for js-html-css there.

L
leclecovich, 2015-02-06
@leclecovich

Look towards Stash, in fact it is a BB clone adapted for corporate solutions. In it, you can already configure the work with pull requests more flexibly, for example, disabling merge without approving or without building unit tests. Learn more: https://confluence.atlassian.com/plugins/servlet/m...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question