From 207117429c771d992a0f41f97b45c0e23e0bf593 Mon Sep 17 00:00:00 2001 From: zPlus Date: Fri, 5 Aug 2022 07:15:00 +0200 Subject: [PATCH] Add diffstats to Log page. Show changed files and lines. --- static/css/clif.css | 28 ++++++++++++++++++++++++++-- templates/repository/log.html | 8 ++++++++ web.py | 4 +++- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/static/css/clif.css b/static/css/clif.css index 0b4965d..3b51603 100644 --- a/static/css/clif.css +++ b/static/css/clif.css @@ -183,7 +183,15 @@ table.log { padding-bottom: 1rem; } - table.log > thead td.time { + table.log > thead .time { + text-align: right; + } + + table.log > thead .files { + text-align: right; + } + + table.log > thead .lines { text-align: right; } @@ -203,9 +211,25 @@ table.log { white-space: pre-wrap; } - table.log > tbody td.time { + table.log > tbody .time { + text-align: right; + } + + table.log > tbody .files { + text-align: right; + } + + table.log > tbody .lines { text-align: right; } + + table.log > tbody .deletions { + color: red; + } + + table.log > tbody .insertions { + color: green; + } div.threads { diff --git a/templates/repository/log.html b/templates/repository/log.html index c0372e1..696fe32 100644 --- a/templates/repository/log.html +++ b/templates/repository/log.html @@ -40,6 +40,8 @@ ID Message Commit time + Files + Lines @@ -69,6 +71,12 @@ {{ commit_time(commit.commit_time, commit.commit_time_offset)|ago }} + + {{ diff[commit.short_id].stats.files_changed }} + + + -{{ diff[commit.short_id].stats.deletions }}/+{{ diff[commit.short_id].stats.insertions }} + {% endfor %} diff --git a/web.py b/web.py index 80c7971..b1331f9 100644 --- a/web.py +++ b/web.py @@ -492,6 +492,7 @@ def log(repository, revision): except: commits_offset = 0 commits = [] + diff = {} commit_ith = 0 for commit in repo.walk(git_object.id): # Skip the first one (offset) @@ -504,11 +505,12 @@ def log(repository, revision): break commits.append(commit) + diff[commit.short_id] = commit.parents[0].tree.diff_to_tree(commit.tree) return template( 'repository/log.html', heads=heads, head_ref=HEAD, tags=tags, - commits=commits, + commits=commits, diff=diff, log_pagination=LOG_PAGINATION, offset=commits_offset, repository=repository, revision=revision)