summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-06-10 10:41:54 -0400
committerDrew DeVault <sir@cmpwn.com>2019-06-10 10:41:54 -0400
commit0d0b80fbed529491c5fe44d0ffa582ea20868858 (patch)
tree1f7186f25d9a766679c903903b0aba1736456c27
parent4c07823f47065d393bf5dfd1d5838d6ddd079051 (diff)
Fix a few bugs found with test-git-web-interface
-rw-r--r--gitsrht/blueprints/repo.py2
-rw-r--r--gitsrht/blueprints/stats.py5
-rw-r--r--gitsrht/git.py11
3 files changed, 13 insertions, 5 deletions
diff --git a/gitsrht/blueprints/repo.py b/gitsrht/blueprints/repo.py
index 028c8d6..8bfd374 100644
--- a/gitsrht/blueprints/repo.py
+++ b/gitsrht/blueprints/repo.py
@@ -83,6 +83,8 @@ def summary(owner, repo):
tags = [(ref, git_repo.get(git_repo.references[ref].target))
for ref in git_repo.listall_references()
if ref.startswith("refs/tags/")]
+ tags = [tag for tag in tags
+ if isinstance(tag[1], pygit2.Tag) or isinstance(tag[1], pygit2.Commit)]
tags = sorted(tags, key=lambda c: commit_time(c[1]), reverse=True)
latest_tag = tags[0] if len(tags) else None
return render_template("summary.html", view="summary",
diff --git a/gitsrht/blueprints/stats.py b/gitsrht/blueprints/stats.py
index 82c562b..57a9f3e 100644
--- a/gitsrht/blueprints/stats.py
+++ b/gitsrht/blueprints/stats.py
@@ -32,7 +32,10 @@ def get_contributions(git_repo, tip, since):
if timestamp < since_ts:
break
- week = _week(datetime.fromtimestamp(timestamp))
+ try:
+ week = _week(datetime.fromtimestamp(timestamp))
+ except:
+ continue
user = _user(commit.author.email, commit.author.name)
contributions[user]['commits'] += 1
contributions[user]['weekly'][week] += 1
diff --git a/gitsrht/git.py b/gitsrht/git.py
index d59947b..066aca7 100644
--- a/gitsrht/git.py
+++ b/gitsrht/git.py
@@ -15,10 +15,13 @@ def trim_commit(msg):
def commit_time(commit):
author = commit.author if hasattr(commit, 'author') else commit.tagger
# Time handling in python is so dumb
- tzinfo = timezone(timedelta(minutes=author.offset))
- tzaware = datetime.fromtimestamp(float(author.time), tzinfo)
- diff = datetime.now(timezone.utc) - tzaware
- return datetime.utcnow() - diff
+ try:
+ tzinfo = timezone(timedelta(minutes=author.offset))
+ tzaware = datetime.fromtimestamp(float(author.time), tzinfo)
+ diff = datetime.now(timezone.utc) - tzaware
+ return datetime.utcnow() - diff
+ except:
+ return datetime.utcnow()
def _get_ref(repo, ref):
return repo._get(ref)