问题
We have an account in Github and hosts all of our projects in Github (private repositories).
We want to enforce coding-standard and probably other hooks that we use for internal purpose. We have had these hooks work pretty well for subversion since the repository located in a single place, administering these hooks was excellent.
With Github, looks like I lose an ability to add my hooks in the main repository(?), hence I am struck:
- How do I enforce coding-standard to every member when they push their changes their files to the main repository?
- Is there any way on Github to execute my hooks present is my server before it process any push request?
I am looking for ideas/suggestions to make my life easier, any help is greatly appreciated.
回答1:
I don't think this is a job for the VCS. The thing is that tools that are helping to enforce coding standards are usually working with the source and sometimes with the binaries. For example in Java checkstyle can be run on source, but findbugs needs sources + compiled code. But as I understand running such tools on a patch is not effective enough. Those tools need context.
So I would recommend to create an instance of Continuous Integration Server like Jenkins and have it checkout code from Github if there are new changes, compile and run static analysis tools, the results of the build should be sent out to all team members. It will not only provide you feedback about pushed changes being properly coded, but also provide beneficial feedback if the code is stable from build perspective right away.
回答2:
Like Eugene says, I'm not sure if this is really is a task of a VCS. (but probably there is a place where you can hook this).
Since you're using Github, are you familiar with the Commit Status API? That way you can setup a service (like Jenkins), which automatically checks the coding style, and for example run unit tests so you can see if the pull request is "clean" or "safe".
来源:https://stackoverflow.com/questions/12955088/how-to-enforce-coding-standard-for-the-repository-located-in-github