home » zplus/clif.git
ID: 39f2ca7427272f710cb8fea6edd9d325644f293c
172 lines — 7K — View raw


{% extends "repository/repository.html" %}

{% block page_title %}Commit: {{ commit.id }}{% endblock %}

{% block content %}
    
    <div class="commit">
        <table>
            <tbody>
                <tr>
                    <td>
                        <b>Author</b>
                    </td>
                    <td>
                        {{ commit.author }}
                        {{ commit_time(commit.author.time, commit.author.offset) }}
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Committer</b>
                    </td>
                    <td>
                        {{ commit.committer }}
                        {{ commit_time(commit.committer.time, commit.committer.offset) }}
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Commit ID</b>
                    </td>
                    <td>
                        {{ commit.id }}
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Tree</b>
                    </td>
                    <td>
                        <a href="{{ url('tree', repository=repository[:-4], revision=commit.tree.id) }}">{{ commit.tree.id }}</a>
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>Parent(s)</b>
                    </td>
                    <td>
                        {% for parent in commit.parents %}
                            <a href="{{ url('commit', repository=repository[:-4], commit_id=parent.id) }}">{{ parent.short_id }}</a>
                        {% endfor %}
                    </td>
                </tr>
                <tr>
                    <td>
                        <b>±</b>
                    </td>
                    <td>
                        {{ diff.stats.files_changed }} files changed,
                        {{ diff.stats.insertions }} insertions,
                        {{ diff.stats.deletions }} deletions
                    </td>
                </tr>
            </tbody>
        </table>
        
        <div class="message">{{ commit.message }}</div>
        
        {% for patch in diff %}
        
            <table class="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
                 #}
                
                {# 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 #}
                <thead>
                    <tr>
                        <td colspan="4">
                            -{{ patch.line_stats[2] }}/+{{ patch.line_stats[1] }}
                            
                            {% if patch.delta.status == 1 %}
                                <b title="Added">A</b> {{ patch.delta.new_file.path }}
                            {% endif %}
                            
                            {% if patch.delta.status == 2 %}
                                <b title="Deleted">D</b> {{ patch.delta.old_file.path }}
                            {% endif %}
                            
                            {% if patch.delta.status == 3 %}
                                <b title="Modified">M</b> {{ patch.delta.new_file.path }}
                            {% endif %}
                            
                            {% if patch.delta.status == 4 %}
                                <b title="Renamed">R</b> {{ patch.delta.old_file.path }} -> {{ patch.delta.new_file.path }}
                            {% endif %}
                            
                            {% if patch.delta.status == 5 %}
                                <b title="Copied">C</b> {{ patch.delta.old_file.path }} {{ patch.delta.new_file.path }}
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            old size: {{ patch.delta.old_file.size|human_size(B=true) }}
                            - 
                            new size: {{ patch.delta.new_file.size|human_size(B=true) }}
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            {% if patch.delta.status == 1 %}
                                new file mode: {{ patch.delta.new_file.mode|filemode }}
                            {% elif patch.delta.status == 2 %}
                                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 }}
                                <br />
                                new mode: {{ patch.delta.new_file.mode|filemode }}
                            {% endif %}
                        </td>
                    </tr>
                </thead>
                <tbody>
                    {% if patch.delta.is_binary %}
                        <tr>
                            <td colspan="4">
                                <i>Binary file</i>
                            </td>
                        </tr>
                    {% endif %}
                    
                    {% for hunk in patch.hunks if not patch.delta.is_binary %}
                
                        <tr class="header">
                            <td></td>
                            <td></td>
                            <td></td>
                            <td>{{ hunk.header }}</td>
                        </tr>
                        
                        {% for line in hunk.lines %}
                            <tr class="{{ 'insertion' if line.old_lineno < 0 }} {{ 'deletion' if line.new_lineno < 0 }}">
                                <td class="lineno">
                                    {% if line.old_lineno >= 0 %}
                                        {{ line.old_lineno }}
                                    {% endif %}
                                </td>
                                <td class="lineno">
                                    {% if line.new_lineno >= 0 %}
                                        {{ line.new_lineno }}
                                    {% endif %}
                                </td>
                                <td class="origin">{{ line.origin }}</td>
                                <td class="content">{{ line.content }}</td>
                            </tr>
                        {% endfor %}
                    
                    {% endfor %}
                </tbody>
                
            </table>
        
        {% endfor %}
    </div>

{% endblock %}