Reputation: 429
At our office, one of the biggest problems of working with a team is to force them to use an standard way of documenting and formatting the code.
I was wondering, is there a way of configuring git (either github or a private git server) to allow ONLY the commits that has a certain documentation and code structure format? EG: All php functions must be documented with phpdoc, all the opening brackets must be in the same line of the function definitions, etc.
To summarize, can a git server be configured to parse some files before accepting a push to force users to format all the code according to a standard?
Upvotes: 2
Views: 269
Reputation: 429
I think this is a good approach to what I was looking for:
https://github.com/s0enke/git-hooks/tree/master/phpcs-pre-commit
It's based on executing PHP_CodeSniffer as a pre-commit hook. The git client will allow the commit only if the PHP_CodeSniffer tests are successful.
Upvotes: 1