-
Notifications
You must be signed in to change notification settings - Fork 148
FiPyCommitTicketUpdater
Jonathan Guyer edited this page Sep 26, 2014
·
1 revision
We have activated the trac:CommitTicketUpdater, which requires a hook in the repository in order to work. The [trac:TracRepositoryAdmin#ExplicitSync] has a couple of problems:
* `REV=$(git rev-parse HEAD)` doesn't work at all with a bare repository * even with a working copy, `git rev-parse HEAD` assumes the active branch to be the one the commit was made to. * A `post-commit` hook is inappropriate for the [git://code.matforge.org/nist/fipy.git FiPy repository at matforge] because we don't `commit` to it, we `push`. Therefore we need a `post-receive` hook. * Only the last revision is recorded, but a push will often bring a whole series of revisions with it
An initial stab at a `post-receive` hook is
This is OK, but it suffers from
* Repeated shell calls to `trac-admin` * If the same revisions are pushed again, they will be recorded in the tickets a second time (for example, a working branch is pushed to the repository for testing and review and, upon acceptance, the same revisions are merged to `develop` and pushed again)
The script linked from http://stackoverflow.com/a/9228844/2019542 has some interesting features, but is obsolete for Trac 1.0. The scripts it was derived from offer a more promising foundation.
* the Trac 0.11 scripts use a more elegant Python interface to Trac and record which revisions have already been dealt with in the Trac database * the Trac 0.12 scripts use the modern `trac-admin changeset added` interface, rather than low-level SQL operations the way the Trac 0.11 scripts do
I merged these features in the [attachment:fipy-trac-post-receive-hook.py], using a `TracAdmin()` object to communicate the `changeset added` actions directly with Trac, and recording the "seen" revisions directly in the SQL database.