Version 1 (modified by jacob, 8 years ago) (diff)

Added notes about how I hacked trac so that next time I won't forget.

Hacking Trac for code.djangoproject.com

For posterity -- and for when we upgrade! -- this page contains a list of all the things I've done to modify Trac for code.djangoproject.com.

Plugins

Most of the work comes from a set of plugins from Trac Hacks. This installation is using the following plugins:

Most of them are easy to install -- just check out the source, python setup.py bdist_egg, and copy the egg to plugins.

I did have to make one trivial bug fix for Python 2.3 to the NavHider plugin:

Index: navhider/filter.py
===================================================================
--- navhider/filter.py  (revision 1926)
+++ navhider/filter.py  (working copy)
@@ -4,7 +4,7 @@
 
 try:
     set = set
-except ImportError:
+except NameError:
     from sets import Set as set
 
 __all__ = ['NavHiderModule']

Custom fields

Most of the fields used by out ticket workflow are added using Trac's custom field feature. See the [ticket-custom] section in the ini below.

Configuration

There's a lot of config stuff in trac.ini, much of which is just there by default. These are the important bits:

[browser]
downloadable_paths = /django/trunk, /django/branches/*, /django/tags/*, /django_website
hide_properties = svk:merge, svn:ignore

[navadd]
add_items = reports, simpleticket
reports.target = mainnav
reports.title = Reports
reports.url = /wiki/Reports
simpleticket.target = mainnav
simpleticket.title = New Ticket
simpleticket.url = /simpleticket

[notification]
always_notify_owner = true
always_notify_reporter = true
always_notify_updater = true

[simpleticket]
hide = stage, needs_tests, needs_docs, needs_better_patch

[ticket-custom]
has_patch = checkbox
has_patch.label = Has patch
has_patch.order = 20
needs_better_patch = checkbox
needs_better_patch.label = Patch needs improvement
needs_better_patch.order = 50
needs_docs = checkbox
needs_docs.label = Needs documentation
needs_docs.order = 30
needs_tests = checkbox
needs_tests.label = Needs tests
needs_tests.order = 40
stage = select
stage.label = Triage Stage
stage.options = Unreviewed|Design decision needed|Accepted|Ready for checkin
stage.order = 10
stage.value = 0

[trac]
mainnav = wiki,timeline,browser,reports,tickets,-newticket,simpleticket,search
metanav = -about,login,logout,settings,-help

Hooks

We use a couple of SVN post-commit hooks to send the checkin notifications to django-updates and to update Trac from "Fixed #XXX" messages. Our post-commit hook:

#!/bin/sh

export PYTHONPATH=/home/trac/

REPOS="$1"
REV="$2"
LOG=`/usr/bin/svnlook log -r $REV $REPOS`
AUTHOR=`/usr/bin/svnlook author -r $REV $REPOS`
TRAC_ENV='/home/trac/django.tracenv/'
TRAC_URL='http://code.djangoproject.com/'

/usr/bin/python2.3 /home/trac/trac-0.10.3/contrib/trac-post-commit-hook \
    -p "$TRAC_ENV"  \
    -r "$REV"       \
    -u "$AUTHOR"    \
    -m "$LOG"       \
    -s "$TRAC_URL"

/home/svn/django/hooks/commit-email.pl \    
    "$REPOS" \
    "$REV" \
    -s "[Changeset]" \
    --from noreply@djangoproject.com \
    django-updates@googlegroups.com

Templates

I've deliberately avoided hacking any built-in trac templates so that upgrades aren't quite so painful. I've thus only edited site_css.cs site_footer.cs}, site_header.cs, and site_newticket.cs.

Back to Top