| 1 | = Using a Subversion commit hook To Interact With TimingAndEstimationPlugin = |
| 2 | |
| 3 | '''Note: This information was taken from http://trac.edgewall.org/wiki/TimeTracking#UsingaSubversioncommithookoptional''' |
| 4 | |
| 5 | The {{{contrib/trac-post-commit-hook}}} script is a very convenient tool to interact with Trac's ticket system on commit. It allows to modify time tracking values and ticket state through special commit messages. |
| 6 | |
| 7 | * Copy {{{trac-post-commit-hook}}} into /usr/share/trac/contrib. |
| 8 | * Create a script {{{hooks/post-commit}}} in your Subversion repository with the content below (modify '''TRAC_ENV''' to point to your local Trac project). |
| 9 | * Set the executable bit: {{{chmod 755 hooks/post-commit}}}. |
| 10 | |
| 11 | {{{ |
| 12 | REPOS="$1" |
| 13 | REV="$2" |
| 14 | LOG=`svnlook log -r $REV $REPOS` |
| 15 | AUTHOR=`svnlook author -r $REV $REPOS` |
| 16 | TRAC_ENV='/var/trac/test' |
| 17 | |
| 18 | /usr/bin/python /usr/share/trac/contrib/trac-post-commit-hook \ |
| 19 | -p "$TRAC_ENV" \ |
| 20 | -r "$REV" \ |
| 21 | -u "$AUTHOR" \ |
| 22 | -m "$LOG" |
| 23 | }}} |
| 24 | |
| 25 | You can now use special keywords in your commit message to modify Trac tickets. The available commands are: |
| 26 | |
| 27 | ||refs #id||Adds a reference to the ticket's Changelog|| |
| 28 | ||re #id||Adds a reference to the ticket's Changelog|| |
| 29 | ||closes #id||Closes the ticket|| |
| 30 | ||fixes #id||Closes the ticket|| |
| 31 | |
| 32 | The time spent is specified in parenthesis. : |
| 33 | ex. re #853 (1) adds one hour to |
| 34 | |
| 35 | |
| 36 | |
| 37 | See {{{contrib/trac-post-commit-hook}}} for details (after applying the patch). |
| 38 | |
| 39 | '''Examples:''' |
| 40 | |
| 41 | {{{ |
| 42 | svn commit -m 'Added time tracking, closes #1 (1), refs #2 (.5)' |
| 43 | }}} |
| 44 | |
| 45 | This closes ticket #1, increases the time spent by 1 hour. It adds an entry to the Changelog of ticket #2, increases the time spent by .5 hours. |