3

I'm using trac v1 (which includes the Git plugin) on linux to trac multiple git repositories within the same trac installation. When I add a new repository to this trac installation it tells me:

"You should also set up a post-commit hook on the repository to call trac-admin $ENV changeset added "kontrolla-sample" $REV for each committed changeset."

Can someone show an example of how the post-commit file should be edited to achieve this?

geoidesic
  • 4,649
  • 3
  • 39
  • 59

1 Answers1

4

See http://trac.edgewall.org/wiki/TracRepositoryAdmin#ExplicitSync for examples and details about what is needed from a post-commit hook script (or more accurately, post-receive for git). Essentially, the script needs to call trac-admin /your/trac/path/here changeset added "(default)" <revision>. If the commit is to a repository other than the default repo, change (default) to the name of the repository.

bta
  • 43,959
  • 6
  • 69
  • 99
  • In fact, there is an [Example](http://trac.edgewall.org/wiki/TracRepositoryAdmin#Git) at the link you provided that works after setting the path and repository, so it should require very little effort to setup. – RjOllos Oct 09 '13 at 21:27
  • I hope this works in the standard case in which a Trac environment is linked to a clone of the repository and changesets are only ever pulled in rather than committed. I'm optimistic, though, as Trac has so far impressed the heck out of me in its general usability. :-) – Tom Russell Jul 12 '17 at 21:32
  • `post-receive` does seem to work as the Trac documentation states. Very cool. I ran across some confusing information about it being only for "the server", but the hook apparently does get called when doing a `git pull` within a clone. – Tom Russell Jul 12 '17 at 23:43
  • Here's the confusing page that refers to `post-receive` as a "server-side" hook: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks – Tom Russell Jul 12 '17 at 23:54