Modify ↓
Opened 16 years ago
Last modified 10 years ago
#7033 new enhancement
SVN Pre-Commit Hook to ensure Trac ID in Comment
| Reported by: | Olemis Lang | Owned by: | Olemis Lang |
|---|---|---|---|
| Priority: | high | Component: | RepositoryHookSystemPlugin |
| Severity: | normal | Keywords: | vcs multi-projects svn |
| Cc: | Trac Release: | 0.11 |
Description
Based on a support request posted by Marjory L. Mackes to trac-users ML
Implement the pre-commit hook /apps/trac/var/svn/hooks/pre-commit.pl , which requires the user to enter the Trac ID number to check in the source to associate the change set with the ticket.
Besides , when multiple environments share a single repository, check whether filters are applied in order to execute hook subscribers only if the target changeset touches the project folder .
Attachments (0)
Change History (2)
comment:2 Changed 10 years ago by
| Keywords: | multi-projects added; multiproject removed |
|---|
Note: See
TracTickets for help on using
tickets.



Ticket status via trac admin They say that they don't want to implement it -> trac:#561 I do not like the sql solution, that is why added the following hack into trac-admin:
../trac/ticket/admin.py
class TicketAdmin(Component): ... def get_admin_commands(self): ... yield ('ticket status', '<number> [...]', 'Status of a ticket', None, self._do_ticket_status) def _do_ticket_status(self, number, *comment): try: number = int(number) except ValueError: raise AdminCommandError(_('<number> must be a number')) ticket = model.Ticket(self.env, number) printout(_('%(t)s', t=ticket.values.get('status')))Now you can request the status of a ticket via
trac-admin %env% ticket status %ticketNo%pre-commit Here my pre-commit script for svn. I have to following folder structure:
../trac/project1
../trac/project2
../svn/project1
../svn/project2
That is why i am doing
tracEnv = repos.replace("svn", "trac")to find the trac environment path. (Can be optimized and enhanced for multiple environments which share a single repository). To commit to a ticket i use the following comment layout#7033 - SVN Pre-Commit Hook to ensure Trac ID in Comment#!/usr/bin/env python import os, sys repos = sys.argv[1] txn = sys.argv[2] svnlook = "/usr/bin/svnlook log -t %s %s" % (txn, repos) text = os.popen(svnlook).read() text = text.split(" ")[0] ticketNo = text.replace("#","") ticketNo = ticketNo.replace("\n","") if (ticketNo.isdigit() == False): sys.stderr.write("This %s is not a number. Please insert a valid ticket number and description in the comment before you commit." %ticketNo) sys.exit(1) #trac environemnt tracEnv = repos.replace("svn", "trac") ticketStatusRequest = "trac-admin %s ticket status %s" % (tracEnv, ticketNo) ticketStatus = os.popen(ticketStatusRequest).read() ticketStatus = ticketStatus.replace("\n","") if (ticketStatus == "new" or ticketStatus == "reopened"): sys.exit(0) else: if (ticketStatus == ""): sys.stderr.write("Ticket %s does not exist." % ticketNo) else: sys.stderr.write("Ticket %s is closed. TicketStatus=%s" % (ticketNo, ticketStatus)) sys.exit(1)