157
|
157
|
|
{% else %}
|
158
|
158
|
|
|
159
|
159
|
|
{% for patch in diff %}
|
160
|
|
- |
|
|
160
|
+ |
|
|
161
|
+ |
{# The following status values are defined in the git_delta_t enum
|
|
162
|
+ |
# in libgit2. See https://github.com/libgit2/libgit2/blob/main/include/git2/diff.h
|
|
163
|
+ |
# Looks like pygit2 also has a pygit2.DiffDelta.status_char() functions that
|
|
164
|
+ |
# returns the single-char abbreviation of the delta status, so we can use this
|
|
165
|
+ |
# instead of the raw integer.
|
|
166
|
+ |
# 0 = UNCHANGED
|
|
167
|
+ |
# 1 = ADDED (does not exist in old version)
|
|
168
|
+ |
# 2 = DELETED (does not exist in new version)
|
|
169
|
+ |
# 3 = MODIFIED (content changed between old and new versions)
|
|
170
|
+ |
# 4 = RENAMED
|
|
171
|
+ |
# 5 = COPIED
|
|
172
|
+ |
# ... (there are other codes that we don't use)
|
|
173
|
+ |
#}
|
|
174
|
+ |
|
|
175
|
+ |
{% set delta_char = patch.delta.status_char() %}
|
|
176
|
+ |
|
161
|
177
|
|
<details class="diff_view" id="{{ (patch.delta.new_file.id|string)[:7] }}" {{ 'open' if defaults.DIFF_EXPAND }}>
|
162
|
178
|
|
|
163
|
|
- |
{# The following status values are defined in the git_delta_t enum
|
164
|
|
- |
# in libgit2. See https://github.com/libgit2/libgit2/blob/main/include/git2/diff.h
|
165
|
|
- |
# 0 = UNCHANGED
|
166
|
|
- |
# 1 = ADDED (does not exist in old version)
|
167
|
|
- |
# 2 = DELETED (does not exist in new version)
|
168
|
|
- |
# 3 = MODIFIED (content changed between old and new versions)
|
169
|
|
- |
# 4 = RENAMED
|
170
|
|
- |
# 5 = COPIED
|
171
|
|
- |
# ... (there are other codes that we don't use)
|
172
|
|
- |
#}
|
173
|
179
|
|
<summary>
|
174
|
180
|
|
{% if patch.line_stats[1] + patch.line_stats[2] > 0 %}
|
175
|
181
|
|
{% set color_border = patch.line_stats[1] / ( patch.line_stats[1] + patch.line_stats[2] ) * 100 %}
|
181
|
187
|
|
+{{ patch.line_stats[1] }}/-{{ patch.line_stats[2] }}
|
182
|
188
|
|
</span>
|
183
|
189
|
|
|
184
|
|
- |
{% if patch.delta.status == 1 %}
|
|
190
|
+ |
{% if delta_char == 'A' %}
|
185
|
191
|
|
<b title="Added">A</b> {{ patch.delta.new_file.path }}
|
186
|
192
|
|
{% endif %}
|
187
|
193
|
|
|
188
|
|
- |
{% if patch.delta.status == 2 %}
|
|
194
|
+ |
{% if delta_char == 'D' %}
|
189
|
195
|
|
<b title="Deleted">D</b> {{ patch.delta.old_file.path }}
|
190
|
196
|
|
{% endif %}
|
191
|
197
|
|
|
192
|
|
- |
{% if patch.delta.status == 3 %}
|
|
198
|
+ |
{% if delta_char == 'M' %}
|
193
|
199
|
|
<b title="Modified">M</b> {{ patch.delta.new_file.path }}
|
194
|
200
|
|
{% endif %}
|
195
|
201
|
|
|
196
|
|
- |
{% if patch.delta.status == 4 %}
|
|
202
|
+ |
{% if delta_char == 'R' %}
|
197
|
203
|
|
<b title="Renamed">R</b> {{ patch.delta.old_file.path }} -> {{ patch.delta.new_file.path }}
|
198
|
204
|
|
{% endif %}
|
199
|
205
|
|
|
200
|
|
- |
{% if patch.delta.status == 5 %}
|
201
|
|
- |
<b title="Copied">C</b> {{ patch.delta.old_file.path }} {{ patch.delta.new_file.path }}
|
|
206
|
+ |
{% if delta_char == 'C' %}
|
|
207
|
+ |
<b title="Copied">C</b> {{ patch.delta.old_file.path }} -> {{ patch.delta.new_file.path }}
|
202
|
208
|
|
{% endif %}
|
203
|
209
|
|
|
204
|
210
|
|
<table>
|
216
|
222
|
|
</tr>
|
217
|
223
|
|
<tr>
|
218
|
224
|
|
<td colspan="4">
|
219
|
|
- |
{% if patch.delta.status == 1 %}
|
|
225
|
+ |
{% if delta_char == 'A' %}
|
220
|
226
|
|
new file mode: {{ patch.delta.new_file.mode|filemode }}
|
221
|
|
- |
{% elif patch.delta.status == 2 %}
|
|
227
|
+ |
{% elif delta_char == 'D' %}
|
222
|
228
|
|
deleted file mode: {{ patch.delta.old_file.mode|filemode }}
|
223
|
229
|
|
{% elif patch.delta.old_file.mode != patch.delta.new_file.mode %}
|
224
|
230
|
|
old mode: {{ patch.delta.old_file.mode|filemode }}
|