I would like to provide integration hooks on top of Git such that pushes get rejected when the integration failed. For example when a developer pushes his changes, I would like to check that the project still compiles successfully.
Presently, I setup the post-update hook to do the compilation checking. However when I want to reject the push, I revert the changes and inform the developer about it :
git revert --no-edit HEAD
echo "Rejected !"
My issue is that when another developer wants to push his changes, he has to pull first thus overriding his work and then needs to issue painful reset/stash commands to merge correctly.
Moreover, the revert will not work in case of branch merging (which needs the -m option)
My current workaround is that instead of reverting on the server, I merge the changes in another branch (which is the default pull origin for my developers):
git checkout integrated
git merge master
What is the best approach to achieve this goal ?
Best approach for this would be giving developers their own feature branches which have post-update hook that checks the compiling and then merges it into master (If you want to go all paranoid on this you can make the hook push to another branch which you merge to master manually). This way you don't have to worry about it being rejected. In my opinion master should be only used as a release branch a reference point not something that everyone pushes everything to.