homeworkprod/klaus — comment on commit a768d12aaad416f7cbbc557ea1d9e4d34704cf9f
File:  line 0
By homeworkprod:

If a repository contains no commits (from which the latest update time should be extracted), the indexed access to the list fails:

```pytb
Traceback (most recent call last):
File "../nano/nano.py", line 180, in __call__
retval = callback(environ, **kwargs)
File "../klaus.py", line 64, in wrapper
**callback(env, **kwargs))
File "../klaus.py", line 221, in __init__
self.view()
File "../klaus.py", line 248, in view
repos.append((name, refs[0].commit_time))
IndexError: list index out of range
```
(Note that the line numbers given for ```klaus.py``` might be slightly off.)

I also renamed the object reference ```head``` to something I consider unambiguous.

The patch uses ``None`` as placeholder and adds a fallback clause (and output message) to the template, which would raise this error otherwise:

```pytb
Traceback (most recent call last):
File "../nano/nano.py", line 180, in __call__
retval = callback(environ, **kwargs)
File "../klaus.py", line 64, in wrapper
**callback(env, **kwargs))
File "../klaus.py", line 73, in render_template
return self.jinja_env.get_template(template_name).render(**kwargs)
File "/var/www/klaus/env/local/lib/python2.7/site-packages/jinja2/environment.py", line 894, in render
return self.environment.handle_exception(exc_info, True)
File "../templates/repo_list.html", line 1, in top-level template code
{% extends 'skeleton.html' %}
File "../templates/skeleton.html", line 13, in top-level template code
{% block content %}{% endblock %}
File "../templates/repo_list.html", line 16, in block "content"
last updated {{ head|timesince }} ago
File "../klaus.py", line 95, in timesince
delta = now() - when
TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'
```