Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Lets say you have a Git repository, like on GitHub, and you have a lot of people contributing to the repository. Everyone uses their own standards for coding, so the code ends up being a mess without any standards applied.

I've read a bit about git hooks but I don't fully understand their concept or primary uses.

Is it possible to use hooks, when a pull request is sent to your repository, to send the code to some remote service, that then formats the code into whatever XYZ standard you want to use, and then returns the formatted code back in to the repo or into the pull request? Or does it not work like that?

share|improve this question
add comment

1 Answer

Sure, you could do something like that. However, I don't like the idea of a third-party service or daemon making changes to code that are committed by my engineers.

So instead of fixing this retroactively, Just check the code via the pre-receive hook and then reject the push if it fails to meet your code style standards. Your engineers really ought to be able to get over their own personal ideas of how code should be formatted and adhere to the organization's desires.

share|improve this answer
    
More than that, suppose it automatically changed the pull request to have formatted code before pulling. You just generated a future merge conflict for that collaborator. Do it enough times and your collaborators will revolt. –  Christopher Aug 10 '12 at 23:05
1  
They aren't "my engineers". Just a group of random people collaborating on a project. If I sit there and reject people's code over and over cause of poor formatting then they are going to just stop contributing. –  Jakobud Aug 12 '12 at 6:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.