~adeuring/charmworld/1199790-last-change-error

« back to all changes in this revision

Viewing changes to charmworld/views/helpers.py

  • Committer: Abel Deuring
  • Date: 2013-07-31 14:45:14 UTC
  • Revision ID: adeuring@gmx.net-20130731144514-mvk81dxv5he4ty87
Return dummy data for Charm.last_change and Charm.first_change, if a branch does not have any commits.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
def format_change(change, charm=None):
14
14
    """Format a bzr commit."""
15
15
    parts = []
16
 
    date = datetime.utcfromtimestamp(change["created"])
17
 
    parts.append(unicode(date.strftime("%Y/%m/%d")))
 
16
    date = change["created"]
 
17
    # bug 1199790: We may have a branch without any commits.
 
18
    # In this case, class Charm returns dummy data for its attributes
 
19
    # first_change and last_change.
 
20
    if date is not None:
 
21
        date = datetime.utcfromtimestamp(date)
 
22
        parts.append(unicode(date.strftime("%Y/%m/%d")))
18
23
    parts.append(name_filter(change['committer']))
19
24
    parts.append(change["message"][:100])
20
25
    if charm is not None: