{% macro breadcrumb(ref, permaref, repo, path, entry, view, path_join, stat, pygit2, humanize, current_user) %} {% if ref != repo.git_repo.default_branch_name() %} ref: {{ ref }} {% endif %} {% if path != [''] %} {{repo.name}}{% endif %}/{% for part in path%}{% if loop.last %}{{part}}{% else %}{{part}}/{% endif %}{% endfor %} {% set is_blob = entry and entry.type == pygit2.GIT_OBJECT_BLOB %} {% if entry %} {# Root tree has no filemode #} {% set filemode = entry.filemode or stat.S_IFDIR %} {{stat.filemode(filemode)}} {% if is_blob %} {{humanize.naturalsize(entry.size, binary=True).replace("Byte", "byte")}} {% endif %} {% endif %} {% set path = path_join(*path) %}
{{ c.message | commit_links(repo) | safe }}
{%- if diff %}
{{diffstat(diff, anchor=str(c.id) + "-")}}{% endif -%}
{% else %}
{{ trim_commit(c.message) }}
{% endif %}
{% endif %}
{% endmacro %}
{% macro commit_diff(repo, commit, diff, anchor="", target_blank=False) %}
{# God, working with tags is such a fucking mess #}
{% if diff.stats.insertions + diff.stats.deletions > 10000 %}
This diff is too large to display. Try viewing the raw diff
instead.
{% else %}
{% for patch in diff %}
{#
#}{{patch.delta.status_char()}} {% if parent %}{{patch.delta.old_file.raw_path.decode('utf-8', 'replace')}}{#
#}{% endif %} => {#
#}{{patch.delta.new_file.raw_path.decode('utf-8', 'replace')}}{#
#} +{{patch.line_stats[1]}}{#
#} -{{patch.line_stats[2]}}{%
if patch.delta.old_file.mode != patch.delta.new_file.mode %}{#
#}{#
#}{% endif %}
{% if patch.hunks|length %}
{% for hunk in patch.hunks %}
{% set hunk_index = loop.index %}@@ {#
#}{% if parent %}{{hunk.old_start}},{{hunk.old_lines}} {#
#}{% endif %}{{hunk.new_start}},{{hunk.new_lines}} {#
#}@@{{hunk.header.split('@@')[-1][:-1]}}
{% for line in hunk.lines
%}{{line.content}}{#
#}{% endfor %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endmacro %}