Reputation: 3562
I have upgraded trac from 0.10 to 1.0 recently, and successfully linked the trac instance to svn and git repositories.
However, I got some major problems during set up of git repositories post-receive hook.
I tried the plugin scripts here:
http://trac-hacks.org/wiki/GitPlugin#post-receivehookscripts
but that does not work, as git post receive does not seems provide $OLD_REV and $NEW_REV in the standard input.
The wiki also mentioned that, one only needs to call the following
trac-admin TRAC_ENV changeset added <commitid(s)>
So I put the following in the post-receive script of git,
REV=$(git rev-parse HEAD)
trac-admin <trac-repo> changeset added <repo-name> $REV
It does work most of the time. However, if the user try to push multiple commits at a time, git rev-parse HEAD
would only retrieve the last commit ID (instead of a list of commit ID belonging to the last push), so some commits would be missed from Trac (from the node_change
table of trac db).
I wonder if there are some ways to get all the commit ID's of latest git push? Or I actually overlooked something here, and there are some more trivial ways to do that?
thanks.
Upvotes: 1
Views: 1641
Reputation: 5201
Please check out this gist that prevents duplication of commits when you use more than one branch:
https://gist.github.com/kenaniah/5471280
Upvotes: 0
Reputation: 3562
ok, I just found this link:
git: empty arguments in post-receive hook
which gave me a great hint, and here is how I solved the problem
In the post-receive
of git:
read oldrev newrev refname
REV=$(git rev-list $oldrev..$newrev)
trac-admin <trac-repo> changeset added <repo-name> $REV
p.s. that means the revision info are indeed passed into script via standard input, just the trac plugin could not get it for some reason.
Upvotes: 2