Edgewall Software
Modify

Opened 18 years ago

Closed 18 years ago

#4035 closed defect (fixed)

trac-post-commit-hook broken in trunk@HEAD

Reported by: exarkun@… Owned by: Christian Boos
Priority: low Milestone: 0.11
Component: version control Version: devel
Severity: minor Keywords: post-commit hook
Cc: exarkun@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

It passes an integer to Ticket.notify and Ticket.save_changes, but apparently a datetime object is expected now. This blows up.

Attachments (0)

Change History (3)

comment:1 by exarkun@…, 18 years ago

Here's an ugly patch which seems to fix the problem. The code isn't factored for testability so I didn't write any unit tests.

  • contrib/trac-post-commit-hook

     
    7272import os
    7373import sys
    7474import time
     75import datetime
    7576
    7677from trac.env import open_environment
    7778from trac.ticket.notification import TicketNotifyEmail
     
    7980from trac.ticket.web_ui import TicketModule
    8081# TODO: move grouped_changelog_entries to model.py
    8182from trac.util.text import to_unicode
     83from trac.util.datefmt import utc
    8284from trac.web.href import Href
    8385
    8486try:
     
    141143        self.author = author
    142144        self.rev = rev
    143145        self.msg = "(In [%s]) %s" % (rev, msg)
    144         self.now = int(time.time())
     146        self.now = datetime.datetime.now(utc)
    145147        self.env = open_environment(project)
    146148        if url is None:
    147149            url = self.env.config.get('project', 'url')
     
    179181                tn = TicketNotifyEmail(self.env)
    180182                tn.notify(ticket, newticket=0, modtime=self.now)
    181183            except Exception, e:
    182                 # import traceback
    183                 # traceback.print_exc(file=sys.stderr)
     184                import traceback
     185                traceback.print_exc(file=sys.stderr)
    184186                print>>sys.stderr, 'Unexpected error while processing ticket ' \
    185187                                   'ID %s: %s' % (tkt_id, e)
    186188           

comment:2 by Christian Boos, 18 years ago

Component: generalversion control
Keywords: post-commit hook added
Milestone: 0.11
Owner: changed from Jonas Borgström to Christian Boos
Priority: normallow
Severity: normalminor

Well, besides the datetime.datetime that we usually avoid by doing from datetime import datetime, I don't see what is ugly in that patch ;)

comment:3 by Christian Boos, 18 years ago

Resolution: fixed
Status: newclosed

This was fixed in r4159.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.