Add git_service_hook() for handling generic Git hooks.

Mostly (slightly) reworked code from github/bitbucket_hook().
Use git_service_hook() for Bitbucket.
Use git_service_hook() for GitHub.
Clean up coding style.