a73x

9d67c2bd

add commit diff page

a73x   2026-03-30 19:07

Adds DiffTemplate and diff handler. compute_diff_lines() diffs the
commit's tree against its parent using DiffFormat::Patch, coloring
add/del/hunk/file lines. Route: /{repo}/diff/{oid}.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

diff --git a/src/server/http/templates/diff.html b/src/server/http/templates/diff.html
new file mode 100644
index 0000000..a41eab3
--- /dev/null
+++ b/src/server/http/templates/diff.html
@@ -0,0 +1,14 @@
{% extends "repo_base.html" %}

{% block title %}{{ short_id }} — {{ repo_name }} — {{ site_title }}{% endblock %}

{% block content %}
<h2 class="mono">{{ short_id }}</h2>
<p><strong>{{ summary }}</strong></p>
<p style="color: var(--text-muted);">{{ author }} &nbsp; {{ date }}</p>
{% if !body.is_empty() %}
<pre style="background: var(--bg-code, #f6f8fa); padding: 12px; border-radius: 4px; white-space: pre-wrap;">{{ body }}</pre>
{% endif %}
<hr style="margin: 16px 0;">
<pre class="diff">{% for line in diff_lines %}{% if line.kind == "add" %}<span class="diff-add">{{ line.text }}</span>{% elif line.kind == "del" %}<span class="diff-del">{{ line.text }}</span>{% elif line.kind == "hunk" %}<span class="diff-hunk">{{ line.text }}</span>{% elif line.kind == "file" %}<span class="diff-file">{{ line.text }}</span>{% else %}{{ line.text }}{% endif %}{% endfor %}</pre>
{% endblock %}