-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
In a corporate setting where git is used, there is typically an "upstream" or "public" repository. And then developers have their "private" repositories. For their day-to-day work, the developers use their private repositories. Periodically, they (either directly, or via gatekeepers) push changes from their private repository to the "upstream" one. Also, the "upstream" repository is typically a bare repository, and no actual commits are done here.
In the private repository, the hook should be installed, but only partically. Every time a commit is made, the hook only checks to make sure that the commit text conforms to correct formatting (i.e. the magic references to Trac issues are present). No Trac issues are updated.
The hook is completely installed in the "upstream" repository.
Whenever a commit is made in the upstream repository or a "git push" is done to it, the installed hook will kick in and validate the commit message, followed by update of the Trac issue.
Copy this script to <upstream-repo-GIT-dir>/hooks/{pre-receive|post-receive}
and mark it executable
Example:
cp git-trac-hook upstream-project.git/hooks/post-receive
cp git-trac-hook upstream-project.git/hooks/pre-receive
chmod a+x upstream-project.git/hooks/post-receive
chmod a+x upstream-project.git/hooks/pre-receive