[[PageOutline(2-5,Contents,pullout)]] = Ticket Changesets Plugin = == Description == The TracTicketChangesetsPlugin hooks into changeset notifications and searches commit messages for ticket references. Referenced tickets are updated with the commit message, and all concerning changesets for a ticket are presented in a separate section on ticket pages, just above the change history section. The source of this plugin is based on code distributed with Trac 0.12 (tracopt/ticket/commit_updater.py). The plugin works with multiple repositories. Language is translated if Babel is installed. '''This plugin is not compatible with Trac 0.11 or older versions.''' == Bugs/Feature Requests == Existing bugs and feature requests for TracTicketChangesetsPlugin are [report:9?COMPONENT=TracTicketChangesetsPlugin here]. If you have any issues, create a [http://trac-hacks.org/newticket?component=TracTicketChangesetsPlugin&owner=mrelbe new ticket]. === Known Issues === [[TicketQuery(status!=closed&component=TracTicketChangesetsPlugin&type=defect)]] The plugin currently does not reformat ticket-commit-messages produced by Trac 0.11 since I am not confident in how those are formatted. Please [http://trac-hacks.org/newticket?component=TracTicketChangesetsPlugin&owner=mrelbe&summary=Reformat+old+commit+messages request this] together with examples of old ticket-commit-messages, and I will add that capability to this plugin. == Download == Download the zipped source from [download:tracticketchangesetsplugin here]. == Source == You can check out TracTicketChangesetsPlugin from [http://trac-hacks.org/svn/tracticketchangesetsplugin here] using Subversion, or [source:tracticketchangesetsplugin browse the source] with Trac. == Example == The related changesets are presented just above the ordinary change history: [[Image(ticket_changesets_box.gif)]] When several repositories contains changesets relating to a ticket, the content will gracefully be split into one sub-section for each repository. The plugin can be configured to present the box as initially collapsed, or hidden completely when no changesets are related to the ticket. Revision ranges can be presented in compact form, for example [420-422] instead of [420] [421] [422]. The macros `CommitMessage(repo, rev)` and `TicketChangesets(ticket)` are provided to present a commit message for a given repository and revision, and all changesets that are related to a given ticket. Console administration commands are available for resynchronizing relations between tickets and changesets: * `trac-admin /path/to/env ticket_changesets diff` * `trac-admin /path/to/env ticket_changesets reformat` (DANGEROUS!) * `trac-admin /path/to/env ticket_changesets resync` Please see the in-built documentation for more details. == Installation instructions == 1. Enable the plugin by the following in trac.ini: {{{ [components] ticketchangesets.* = enabled }}} 1. Add the section `[ticket-changesets]` to configure the behaviour: {{{ [ticket-changesets] check_perms = true collapsed = false commands.close = close closed closes fix fixed fixes commands.refs = addresses re refs references see ticket tickets compact = true hide_when_none = false notify = false resolution = fixed }}} where: * '''check_perms''': Check that the committer has permission to perform the requested operations on the referenced tickets. This requires that the user names be the same for Trac and repository operations. * '''collapsed''': Show section on ticket page as initially collapsed. * '''commands.close''': Commands that close tickets, as a space-separated list. * '''commands.refs''': Commands that add a reference, as a space-separated list. If set to the special value , all tickets referenced by the message will get a reference to the changeset. * '''compact''': Make compact presentation of revision ranges, for example [1-3] instead of [1] [2] [3]. * '''envelope''': Require commands to be enclosed in an envelope. Must be empty or contain two characters. For example, if set to "[]", then commands must be in the form of [closes #4]. * '''hide_when_none''': Hide section on ticket page when no changesets relates to the ticket. * '''notify''': Send ticket change notification when updating a ticket. * '''resolution''': The resolution to set to a ticket closed by a commit message. 1. The Trac environment needs to be upgraded: {{{ trac-admin /path/to/env upgrade }}} 1. Re-synchronize repositories (optional, but recommended before next step which will scan all existing commit messages): {{{ trac-admin /path/to/env repository resync "*" }}} 1. Build relations between tickets and changesets: {{{ trac-admin /path/to/env ticket_changesets resync }}} 1. Re-format existing ticket commit messages (DANGEROUS!) a. Produce a diff-like output for your analysis, which does not affect the database, before re-formatting existing commit messages: {{{ trac-admin /path/to/env ticket_changesets diff > out.diff }}} Examine out.diff and assert that re-formatting is sensible before next step. a. Re-format '''(DANGEROUS!)''' {{{ trac-admin /path/to/env ticket_changesets reformat }}} 1. Setup hook-scripts (Windows example, does not differ from official instructions applicable to Trac 0.12): a. post-commit.cmd {{{ :: Trac 0.12 post-commit hook script for Windows :: @SET REPOS=%1 @SET REV=%2 @trac-admin /path/to/env changeset added "%REPOS%" "%REV%" }}} a. post-revprop-change.cmd {{{ :: Trac 0.12 post-revprop-change hook script for Windows :: @SET REPOS=%1 @SET REV=%2 @trac-admin /path/to/env changeset modified "%REPOS" "%REV%" }}} From here-on, tickets will be updated when referenced in a commit message, and the relation between tickets and revisions are automatically tracked. == Recent Changes == [[ChangeLog(tracticketchangesetsplugin, 3)]] == Author/Contributors == '''Author:''' [wiki:mrelbe] [[BR]] '''Maintainer:''' [wiki:mrelbe] [[BR]] '''Contributors:'''