{% extends "repository/repository.html" %} {% block page_title %}Commit: {{ commit.id }}{% endblock %} {% block content %}
Author {{ commit.author }} {{ commit_time(commit.author.time, commit.author.offset) }}
Committer {{ commit.committer }} {{ commit_time(commit.committer.time, commit.committer.offset) }}
Commit {{ commit.id }}
Tree {{ commit.tree.id }}
Parent(s) {% for parent in commit.parents %} {{ parent.short_id }} {% endfor %}

{{ commit.message }}




{# pygit2 appears to recompute all the stats every time we use diff.stats, # therefore we set this variable in order to compute it only once. #} {% set diff_stats = diff.stats %} Diffstat {% for patch in diff %} {% endfor %}
{{ patch.delta.new_file.mode|filemode }} {{ patch.delta.new_file.path }} {{ patch.line_stats[1] + patch.line_stats[2] }} {% if diff_stats.insertions + diff_stats.deletions > 0 %} {% endif %}
{{ diff_stats.files_changed }} file{{ 's' if diff_stats.files_changed != 1 }} changed, {{ diff_stats.insertions }} insertion{{ 's' if diff_stats.insertions != 1 }}, {{ diff_stats.deletions }} deletion{{ 's' if diff_stats.deletions != 1 }}

Diff options
View
Context lines
Inter-hunk lines
Side
Whitespace
{% if mode == 'udiff_raw' %}
{{ diff.patch|highlight_udiff|safe }}
{% else %} {% for patch in diff %} {# The following status values are defined in the git_delta_t enum # in libgit2. See https://github.com/libgit2/libgit2/blob/main/include/git2/diff.h # Looks like pygit2 also has a pygit2.DiffDelta.status_char() functions that # returns the single-char abbreviation of the delta status, so we can use this # instead of the raw integer. # 0 = UNCHANGED # 1 = ADDED (does not exist in old version) # 2 = DELETED (does not exist in new version) # 3 = MODIFIED (content changed between old and new versions) # 4 = RENAMED # 5 = COPIED # ... (there are other codes that we don't use) #} {% set delta_char = patch.delta.status_char() %}
{% if patch.line_stats[1] + patch.line_stats[2] > 0 %} {% set color_border = patch.line_stats[1] / ( patch.line_stats[1] + patch.line_stats[2] ) * 100 %} {% else %} {% set color_border = 0 %} {% endif %} +{{ patch.line_stats[1] }}/-{{ patch.line_stats[2] }} {% if delta_char == 'A' %} A   {{ patch.delta.new_file.path }} {% endif %} {% if delta_char == 'D' %} D   {{ patch.delta.old_file.path }} {% endif %} {% if delta_char == 'M' %} M   {{ patch.delta.new_file.path }} {% endif %} {% if delta_char == 'R' %} R   {{ patch.delta.old_file.path }} -> {{ patch.delta.new_file.path }} {% endif %} {% if delta_char == 'C' %} C   {{ patch.delta.old_file.path }} -> {{ patch.delta.new_file.path }} {% endif %}
index {{ (patch.delta.old_file.id|string)[:7] }}..{{ (patch.delta.new_file.id|string)[:7] }}
old size: {{ patch.delta.old_file.size|human_size(B=true) }} - new size: {{ patch.delta.new_file.size|human_size(B=true) }}
{% if delta_char == 'A' %} new file mode: {{ patch.delta.new_file.mode|filemode }} {% elif delta_char == 'D' %} deleted file mode: {{ patch.delta.old_file.mode|filemode }} {% elif patch.delta.old_file.mode != patch.delta.new_file.mode %} old mode: {{ patch.delta.old_file.mode|filemode }}
new mode: {{ patch.delta.new_file.mode|filemode }} {% endif %}
{% if patch.delta.is_binary %} {% endif %} {% for hunk in patch.hunks if not patch.delta.is_binary %} {#### UDIFF mode ####} {# In this mode the lines are printed one after the other. #} {% if mode == 'udiff' %} {% for line in hunk.lines %} {% endfor %} {% endif %} {#### SSDIFF mode ####} {# In this mode, changed lines are buffered until we find an # unchanged line. When an unchanged line has been found, the # buffer is emptied. #} {% if mode == 'ssdiff' %} {% set buffer_deletions = [] %} {% set buffer_insertions = [] %} {% macro print_buffer(buffer_deletions, buffer_insertions) %} {% for buffer_del, buffer_ins in zip_longest(buffer_deletions, buffer_insertions) %} {% if buffer_del %} {% else %} {% endif %} {% if buffer_ins %} {% else %} {% endif %} {% endfor %} {# .clear() empties the buffer. Since this requires {{}} # brackets instead of {%%}, this line will print the value # of "buffer_deletions" which is "None". # "or ''" is a hack for printing an empty line instead of "None". #} {{ buffer_deletions.clear() or '' }} {{ buffer_insertions.clear() or '' }} {% endmacro %} {% for line in hunk.lines %} {% if line.old_lineno < 0 %} {{ buffer_insertions.append(line) or '' }} {% endif %} {% if line.new_lineno < 0 %} {{ buffer_deletions.append(line) or '' }} {% endif %} {% if line.old_lineno >= 0 and line.new_lineno >= 0 %} {# Unload buffer #} {{ print_buffer(buffer_deletions, buffer_insertions) }} {# Insert the unchanged line. #} {% endif %} {% endfor %} {# Empty remaining buffer. There is a non-empty buffer if we did # not find an unchanged line, for example when context_lines=0. #} {{ print_buffer(buffer_deletions, buffer_insertions) }} {% endif %} {% endfor %}
Binary file
{{ hunk.header }}
{% if line.old_lineno >= 0 %} {{ line.old_lineno }} {% endif %} {% if line.new_lineno >= 0 %} {{ line.new_lineno }} {% endif %} {{ line.origin }} {{ line.content }}
{{ buffer_del.old_lineno }} {{ buffer_del.content }} {{ buffer_ins.new_lineno }} {{ buffer_ins.content }}
{{ hunk.header }}
{{ line.old_lineno }} {{ line.content }} {{ line.new_lineno }} {{ line.content }}

{% endfor %} {% endif %}
{% endblock %}