make SVN's post-commit-hook a pluggable Extension Point

This plugin is deprecated -- see the RepositoryHookSystemPlugin for a more generalized solution

source:svnchangelistenerplugin/0.11/svnchangelistener.png

Description

SvnChangeListenerPlugin turns the SVN post-commit-hook into an Extension Point, so that arbitrary plugins can act on changset commits. The guts of the plugin are abstracted from http://trac.edgewall.org/browser/trunk/contrib/trac-post-commit-hook

and the included TicketChanger? plugin is a port from the trac-post-commit-hook as well that plays nice with the SvnChangeListenerPlugin pluggable architecture.

In order to plug in to SvnChangeListenerPlugin, you must import and implement the svnchangelistener.interface.ISVNChangeListener interface, which consists only of an on_change function that takes a trac environment and the changeset object as arguments.

Installation

The plugin and various components must be enabled for the project in the normal fashion. In addition, an appropriate line must be added to the SVN post-commit-hook file:

python /path/to/svnchangelistener/listener.py -p projectname1 [-p projectname2] [...] -r "$2"

A front end to this is available in the webadmin interface, assuming the file is writable. Assuming TRAC_ADMIN access, browse to /admin/svn/changelistener (or click on "Change Listener" it in the SVN section of the webadmin left sidebar). If there is no post-commit-hook yet for the repository, an option will be availble to install a new script (with possibly overly generous permissions, 755). If there is already a post-commit-hook (including one made by this plugin!), the option is given to append a bash-syntax line to the file. In either case, the file may be edited before form submission.

Probably a better manner should be used to configure the SVN post-commit-hook, possibly interfacing with http://trac-hacks.org/wiki/TracSvnPoliciesPlugin

Evaluation

The SvnChangeListenerPlugin makes the contributted post-commit-hook into a pluggable system without any loss of generality. So its a win there. However, there are currently several short-comings, to be ticketed:

  • optionally, the project name should be required in the ticket regex, so that fixes mytrac:#2 closes ticket 2 but fixes #2 does not (useful for multiple tracs, one repo)
  • the post-command-hook should be installable from the command line
  • the webadmin installer should be smarter in figuring out if the plugin is already installed
  • handling of other commit hooks (pre-commit, etc)
  • better editting of hooks; I think the correct solution is showing the hooks in a textarea providing an interface to hook into. This could look like
class HookContributer(Interface):

      def hook():
      	  """name(s) of hooks to contibute to"""

      def name():
      	  """name of the contributor;  this will be added to the hook
      	  with

### ${name} Trac hook
${commandline}

	  so that the hooks can be removed and installed reliably
	  without overlapping.  Maybe a format for command line could
	  be asserted so that this could be parsed too;  i'm thinking
	  multiple projects
	  """

     def commandline(<arguments>):
          """the command line to be added"""

Example

This screenshot of the webadmin screen shows webadmin installation over an existing file:

screenshot of webadmin interface for svn change listener's installer, this screen for appending to a file

The view would be similar if a new post-commit-hook would be made, or if write access was not available on the post-commit-hook then this would be noted.

Bugs/Feature Requests

Existing bugs and feature requests for SvnChangeListenerPlugin are here.

If you have any issues, create a new ticket.

Download

Download the zipped source from here.

Source

You can check out SvnChangeListenerPlugin from here using Subversion, or browse the source with Trac.

Recent Changes

[4388] by k0s on 10/06/08 17:30:55

include package data, hopefully fixes #3703

[4183] by k0s on 08/25/08 21:24:14

take description out of the README -> the wiki

[4182] by k0s on 08/25/08 21:21:15

adding diagram for process flow for SVNChangeListener

[3874] by k0s on 06/20/08 18:06:04

more notes to the README

Author/Contributors

Originally developed at The Open Planning Project

Author: k0s
Contributors:

Attachments