Contents
Update tickets with changeset commit messages
Notice: This plugin is deprecated in Trac 1.2 and later. Please use TracTicketChangelogPlugin and file enhancement requests for any missing features in that plugin.
Description
This plugin 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 to a different locale, provided Babel is installed.
The related changesets are presented just above the ordinary change history:
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
Console administration commands are available for retrieving and re-synchronizing ticket-changesets relations, and reformatting existing ticket commit messages.
trac-admin /path/to/env ticket_changesets diff
- Examine ticket commit messages before reformat.
Generate a diff-like output for analysis before reformatting. The database will not be changed. Before this operation, you may want to run:
trac-admin $ENV repository resync "*"
trac-admin /path/to/env ticket_changesets get [ticketid]
- Get a comma-separated list of related revisions (#7267).
List format:
#ticketid: rev/reponame,... ..."/reponame" is left out for the default repository.
All tickets related to changesets are listed if ticketid is omitted, one ticket on each line. If no ticket-changesets relations exists in the database, "None" is displayed.
trac-admin /path/to/env ticket_changesets reformat
(DANGEROUS!)- Reformat ticket commit messages.
Before this operation, you may want to run:
trac-admin $ENV repository resync "*"
and then analyse the output of:
trac-admin $ENV ticket_changesets diff
trac-admin /path/to/env ticket_changesets resync
- Re-synchronize ticket changesets with all repositories
Relations between tickets and changesets are re-built by examining all commit messages, in all repositories, for ticket references. Ticket comments are neither updated nor added due to new discoveries.
Before this operation, you may want to run:
trac-admin $ENV repository resync "*"
See also: TracTicketChangelogPlugin, TicketModifiedFilesPlugin
Bugs/Feature Requests
Existing bugs and feature requests for TracTicketChangesetsPlugin are here.
If you have any issues, create a new ticket.
defect |
15 / 15 |
|
---|---|---|
enhancement |
14 / 14 |
|
task |
3 / 3 |
Note: 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 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 here.
Source
You can check out TracTicketChangesetsPlugin from here using Subversion, or browse the source with Trac.
Installation
- Install the plugin, even with locale support:
cd TracTicketChangesetsPlugin python setup.py install
- Enable the plugin by the following in your
trac.ini
file:[components] ticketchangesets.* = enabled
Configuration
- Add the section
[ticket-changesets]
to configure the behaviour (default values are shown below):where:[ticket-changesets] check_perms = true collapsed = false commands.close = close closed closes fix fixed fixes commands.refs = addresses re references refs see compact = true envelope = hide_when_none = false notify = true resolution = fixed ticket_comments = true
- 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>, 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.
- ticket_comments: Add a ticket comment based on changeset info, for each referenced ticket. Set to
false
to suppress ticket comments when this plugin is used along with e.g. the commit-ticket-updater plugin offered by Trac (tracopt/ticket/commit_updater.py). If set totrue
, thentracopt.ticket.commit_updater.*
should be set todisabled
. (#7529)
- The Trac environment needs to be upgraded:
trac-admin /path/to/env upgrade
- Re-synchronize repositories (optional, but recommended before next step which will scan all existing commit messages):
trac-admin /path/to/env repository resync "*"
- Build relations between tickets and changesets:
trac-admin /path/to/env ticket_changesets resync
- Re-format existing ticket commit messages: (DANGEROUS!)
- Produce a diff-like output for your analysis, which does not affect the database, before re-formatting existing commit messages:
Examine out.diff and assert that re-formatting is sensible before next step.
trac-admin /path/to/env ticket_changesets diff > out.diff
- Re-format (DANGEROUS!)
trac-admin /path/to/env ticket_changesets reformat
- Produce a diff-like output for your analysis, which does not affect the database, before re-formatting existing commit messages:
- Setup hook-scripts (Windows example, does not differ from official instructions applicable to Trac 0.12):
Note that you may have to set the environment variablePYTHON_EGG_CACHE
to the same value as was used for the web server configuration before calling trac-admin, if you changed it from its default location. See TracRepositoryAdmin#ExplicitSync for more information.- 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%"
- 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%"
- post-commit.cmd:
From here-on tickets will be updated when referenced in a commit message, and the relation between tickets and revisions is automatically tracked.
About i18n/l10n support
The development version of this plugin is prepared for localization.
But English message texts are still the (POSIX) default. If this isn't your preferred language, you can do it yourself. See the l10n cookbook page for Trac plugins for more details.
You've done a new translation? Superb! Contributing your translation is highly appreciated. You could send it to the plugin's maintainer.
Preparing the plugin from source requires no additional step for compiling message catalog files, that's part of a normal installation:
cd TracTicketChangesetsPlugin
python ./setup.py install
Recent Changes
- 17869 by rjollos on 2020-10-26 18:43:59
-
1.0dev: Fix formatting using autopep8
Refs #13897.
- 16184 by rjollos on 2017-01-18 04:23:52
-
1.0dev: Change id to avoid duplicate ids on ticket page
Untested change. Refs #13046.
- 15264 by rjollos on 2016-02-11 04:22:34
-
Remove unnecessary svn:mime-type on py files
svn:mime-type was set to "plain" for many files.
(more)
Author/Contributors
Author: mrelbe
Maintainer: Mikael Relbe
Contributors:
Attachments (1)
- ticket_changesets_box.gif (8.6 KB) - added by 14 years ago.
Download all attachments as: .zip