Add bzr commit notification hook to trac-bzr

Bug #816039 reported by Hendrik van Antwerpen
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Trac-Bzr
Fix Committed
Wishlist
Unassigned

Bug Description

Trac 0.12 includes a plugin[1] to scan commit messages and automatically add comments and close tickets based on keywords in the message. This proces has to be triggered by hand, so it seems useful to include a bzr hook with trac-bzr that does so.

Attached is a proposed hook script that works for simple and shared repositories. The script uses the tip change hook, so it also works on updates and pushes.

The script also registers a command 'trac-project' to easily print and set the trac_project property in branch.conf file. It is not possible to set the trac_project property on a repository. So in a shared repository setup, the property has to be set on every branch. A warning is issued to inform the user about this.

The script could be installed in /usr/share/pyshared/bzrlib/plugins/trac/__init__.py to make it available systemwide as soon as someone installs trac-bzr. I don't know if easy_install and eggs allow all that.

If the script is invoked within a smartserver (e.g. commit to bzr+ssh:// location and the plugin is installed on the remote site), the script fails, complaining about accessing a location outside the server jail. I don't know yet how this can be fixed. I tried calling the trac-admin command by hand, but since I cannot get the local repos url (it gives /) that also failed for now.

[1] http://trac.edgewall.org/wiki/CommitTicketUpdater
[2] http://trac.edgewall.org/wiki/TracRepositoryAdmin#ExplicitSync

Related branches

Revision history for this message
Hendrik van Antwerpen (hendrik-van-antwerpen) wrote :
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Just to note that the hook in trace 0.12 ignores bzr revision properties, so you can't use things like "bzr commit --fixes " with it.

Revision history for this message
IWATA Hidetaka (hid-iwata) wrote :

I have my own trac-commit-hook script.
http://bazaar.launchpad.net/~hid-iwata/+junk/bzr-trac-hook/view/head:/trac_hook.py

In this script, there is some snippets to get local url of chroot and apply location.conf to it
I hope this help you.

Jelmer Vernooij (jelmer)
Changed in trac-bzr:
status: New → Confirmed
importance: Undecided → Medium
importance: Medium → Wishlist
Revision history for this message
Martin von Gagern (gagern) wrote :

As the person who rolled the past few trac-bzr releases: I currently don't have the time to read and compare those commit hooks you offered. It appears that there are two scripts here and one in a branch by Jelmer at bug #120470, which is already being reviewed. It also appears that there is a number of users here who do have the time to think about these matters and even write code.

So I propose the following: can the three of you compare your scripts, review one anothers code, and hopefully come up with a solution offering the best from all three approaches. I'd then love to see a branch from which I can merge both the script and a suitable doc change. lp:~jelmer/trac-bzr/close-bugs already has part of that.

If more than one person tells me that a given piece of code for passing metadata from bzr commits to trac is good and should be included, I'll happily accept it even if I didn't test it myself. If that approach doesn't work, you'll have to wait till I have more time, dunno when that will be.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Please note that my script just closes bugs in trac based on their bzr revision properties. Trac itself doesn't do this, even when it does find the revisions. Hendrik's plugin hooks into bzr to notify trac about new commits, which is different.

I think, apart from the fact that they are both bzr plugins, these are separate topics.

summary: - Add bzr commit hook to track-bzr
+ Add bzr commit notification hook to trac-bzr
Revision history for this message
Martin von Gagern (gagern) wrote : Re: [Bug 816039] Re: Add bzr commit hook to track-bzr

On 31.08.2011 16:21, Jelmer Vernooij wrote:
> Please note that my script just closes bugs in trac based on their bzr
> revision properties. Trac itself doesn't do this, even when it does find
> the revisions. Hendrik's plugin hooks into bzr to notify trac about new
> commits, which is different.
>
> I think, apart from the fact that they are both bzr plugins, these are
> separate topics.

Thanks for the clarification! I read the part about the
CommitTicketUpdater plugin, but missed the general concept behind the
explicit sync. Agreed, these are separate issues, but a single branch to
deal with them both might still be beneficial, in terms of shared dirs
and installer modifications, so thanks for merging this together.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Yeah, I think so too.

I've attached a branch that adds a single bzr plugin with the functionality from both our patches. Feedback welcome.

Changed in trac-bzr:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.