Fix null case of zero commits
Committed 67d654
--- a/webint_code/templates/project/index.html
+++ b/webint_code/templates/project/index.html
$# </div>
$if repo.exists():
- $ commit = list(repo.log().values())[0]
- $ author_url = commit["author_email"]
- $if "@" in author_url:
- $ author_url = f"mailto:{author_url}"
- $else:
- $ author_url = f"https://{author_url}"
- <div class=h-entry>
- $# <a class=u-author href="$author_url">$commit["author_name"]</a>
- <span class=p-name>$:str(mkdn(commit["message"]))[3:-4]</span>
- $if "errors" in test_results:
- $if test_results["errors"]:
- $ test_color = "red"
- $ test_indicator = "■"
- $ plural = ""
- $if test_results["errors"] > 1:
- $ plural = "s"
- $ test_msg = f"{test_results['errors']} test{plural} of {test_results['tests']} failing"
+ $ commits = list(repo.log().values())
+ $if commits:
+ $ commit = commits[0]
+ $ author_url = commit["author_email"]
+ $if "@" in author_url:
+ $ author_url = f"mailto:{author_url}"
$else:
- $ test_color = "green"
- $ test_indicator = "●"
- $ plural = ""
- $if test_results["tests"] > 1:
- $ plural = "s"
- $ test_msg = f"{test_results['tests']} test{plural} passing"
- <span style=color:$test_color>$:test_indicator</span>
- $test_msg in $test_results["time"]<small>s</small>
- <small><small>
- <a class=u-url href=/projects/$project/commits/$commit["hash"]>\
- <code>$commit["hash"][:7].upper()</code> <time class=dt-published \
- datetime=$commit["timestamp"].isoformat()>\
- $:commit["timestamp"].diff_for_humans().replace(" ", " ")</time></a>
- </small></small>
- <a href=/projects/$project/commits><strong>$len(repo.log())</strong> commits</a>
- </div>
+ $ author_url = f"https://{author_url}"
+ <div class=h-entry>
+ $# <a class=u-author href="$author_url">$commit["author_name"]</a>
+ <span class=p-name>$:str(mkdn(commit["message"]))[3:-4]</span>
+ $if "errors" in test_results:
+ $if test_results["errors"]:
+ $ test_color = "red"
+ $ test_indicator = "■"
+ $ plural = ""
+ $if test_results["errors"] > 1:
+ $ plural = "s"
+ $ test_msg = f"{test_results['errors']} test{plural} of {test_results['tests']} failing"
+ $else:
+ $ test_color = "green"
+ $ test_indicator = "●"
+ $ plural = ""
+ $if test_results["tests"] > 1:
+ $ plural = "s"
+ $ test_msg = f"{test_results['tests']} test{plural} passing"
+ <span style=color:$test_color>$:test_indicator</span>
+ $test_msg in $test_results["time"]<small>s</small>
+ <small><small>
+ <a class=u-url href=/projects/$project/commits/$commit["hash"]>\
+ <code>$commit["hash"][:7].upper()</code> <time class=dt-published \
+ datetime=$commit["timestamp"].isoformat()>\
+ $:commit["timestamp"].diff_for_humans().replace(" ", " ")</time></a>
+ </small></small>
+ <a href=/projects/$project/commits><strong>$len(repo.log())</strong> commits</a>
+ </div>
<div id=files>
$ ignorable_files = (