Code standard check at the time of git commit

fotuzlab's picture

Was wondering if we could include pre-commit git hooks in module/theme repositories to check drupal coding standards. (Like the ones provided by http://drupal.org/project/git_hooks).
This would help in standardizing the code on d.o

The only problem I find is ... new contributors may find it irritating and hence put them off.

Thoughts???

Comments

Moving this question from the

webchick's picture

Moving this question from the Drupal Association group to the Drupal.org improvements and Drupal.org Git Team groups.

Thanx. My bad! Didn't know

fotuzlab's picture

Thanx. My bad! Didn't know Drupal.org Improvements exist.

Setup

helmo's picture

Pre-commit hooks need to be setup in everybody's own environment. So that would not scale.

And as you mention we don't want make it harder to contribute.

I think I would prefer a post-receive hook that kicks off a few test.
Giving a gentle hint about code style would be helpful in my opinion.

Why not integrate that with the "Automated testing" tab we already have?

"Pre-commit hooks need to be

fotuzlab's picture

"Pre-commit hooks need to be setup in everybody's own environment. So that would not scale."

Thats right! I was hoping if we could just clone these hooks at the time of checkout.

Nonetheless, adding a post receive hook sounds better. Send it as an email?

There is a problem with tests

aspilicious's picture

There is a problem with tests and files from external libraries.
Sometimes they contain tabs and other problems on purpose.

Maybe we can add a special suffix to a patch to overcome that problem.
For example we could end those patches with -has-known-formatting-issues.

thisIsApatch-has-known-formatting-issues.patch

Sounds stupid but I think thats the best we can do. Or are there better options?

EDIT: on local commits this can lead to potential problems...