From 836e00f67ba2c67a89a9b62092743c44985a8a2a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 23 Jul 2019 20:16:52 +0200 Subject: Add commits-since-tag This patch adds a "commits since tag" output in the refs view. --- gitsrht/git.py | 7 +++++++ gitsrht/templates/refs.html | 3 +++ 2 files changed, 10 insertions(+) diff --git a/gitsrht/git.py b/gitsrht/git.py index e6808b9..0e6f938 100644 --- a/gitsrht/git.py +++ b/gitsrht/git.py @@ -12,6 +12,13 @@ def trim_commit(msg): return msg return msg[:msg.index("\n")] +def commits_since_rev(repo, rev): + i = 0 + for commit in repo.walk(repo.head.target): + if commit.id == rev: + break + return i + def commit_time(commit): author = commit.author if hasattr(commit, 'author') else commit.tagger # Time handling in python is so dumb diff --git a/gitsrht/templates/refs.html b/gitsrht/templates/refs.html index 14d0211..e8d1c26 100644 --- a/gitsrht/templates/refs.html +++ b/gitsrht/templates/refs.html @@ -46,6 +46,9 @@ {% endif %} + + {{commits_since_rev(repo, tag)}} + {{commit_time(tag) | date}}