Files
@ f950740985f4
Branch filter:
Location: kallithea/kallithea/templates/changelog/changelog_table.html
f950740985f4
5.5 KiB
text/html
changelog: fix crash on display of empty commit messages
Also handle commit messages with leading whitespace.
.splitlines() is different from .split('\n') and will give an empty list when
given an empty string.
Problem reported and initial patch proposed by Brett Smith.
Also handle commit messages with leading whitespace.
.splitlines() is different from .split('\n') and will give an empty list when
given an empty string.
Problem reported and initial patch proposed by Brett Smith.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | ## Render changelog table with id 'changesets' with the range of changesets,
## statuses, and comments.
## Optionally, pass a js snippet to run whenever a table resize is triggered.
<%def name="changelog(repo_name, cs_range, cs_statuses, cs_comments, show_checkbox=False, show_branch=True, show_index=False, resize_js='')">
<% num_cs = len(cs_range) %>
<table class="table" id="changesets">
<tbody>
%for cnt,cs in enumerate(cs_range):
<tr id="chg_${cnt+1}" class="${'mergerow' if len(cs.parents) > 1 else ''}">
%if show_checkbox:
<td class="checkbox-column">
${h.checkbox(cs.raw_id,class_="changeset_range")}
</td>
%endif
%if show_index:
<td class="changeset-logical-index">
<%
index = num_cs - cnt
if index == 1:
title = _('First (oldest) changeset in this list')
elif index == num_cs:
title = _('Last (most recent) changeset in this list')
else:
title = _('Position in this list of changesets')
%>
<span data-toggle="tooltip" title="${title}">
${index}
</span>
</td>
%endif
<td class="status">
%if cs_statuses.get(cs.raw_id):
%if cs_statuses.get(cs.raw_id)[2]:
<a data-toggle="tooltip"
title="${_('Changeset status: %s by %s\nClick to open associated pull request %s') % (cs_statuses.get(cs.raw_id)[1], cs_statuses.get(cs.raw_id)[5].username, cs_statuses.get(cs.raw_id)[4])}"
href="${h.url('pullrequest_show',repo_name=cs_statuses.get(cs.raw_id)[3],pull_request_id=cs_statuses.get(cs.raw_id)[2])}">
<i class="icon-circle changeset-status-${cs_statuses.get(cs.raw_id)[0]}"></i>
</a>
%else:
<a data-toggle="tooltip"
title="${_('Changeset status: %s by %s') % (cs_statuses.get(cs.raw_id)[1], cs_statuses.get(cs.raw_id)[5].username)}"
href="${cs_comments[cs.raw_id][0].url()}">
<i class="icon-circle changeset-status-${cs_statuses.get(cs.raw_id)[0]}"></i>
</a>
%endif
%endif
</td>
<td class="author" data-toggle="tooltip" title="${cs.author}">
${h.gravatar(h.email_or_none(cs.author), size=16)}
<span class="user">${h.person(cs.author)}</span>
</td>
<td class="hash">
${h.link_to(h.show_id(cs),h.url('changeset_home',repo_name=repo_name,revision=cs.raw_id), class_='changeset_hash')}
</td>
<td class="date">
<div data-toggle="tooltip" title="${h.fmt_date(cs.date)}">${h.age(cs.date,True)}</div>
</td>
<% message_lines = cs.message.strip().splitlines() or [_("(No commit message)")] %>
%if len(message_lines) > 1:
<td class="expand_commit" title="${_('Expand commit message')}">
<i class="icon-align-left"></i>
</td>
%else:
<td class="expand_commit"></td>
%endif
<td class="mid">
<div class="log-container">
<div class="message">
<div class="message-firstline">${h.urlify_text(message_lines[0], c.repo_name,h.url('changeset_home',repo_name=repo_name,revision=cs.raw_id))}</div>
%if len(message_lines) > 1:
<div class="message-full hidden">${h.urlify_text(cs.message, repo_name)}</div>
%endif
</div>
<div class="extra-container">
%if cs_comments.get(cs.raw_id):
<a class="comments-container comments-cnt" href="${cs_comments[cs.raw_id][0].url()}" data-toggle="tooltip" title="${_('%s comments') % len(cs_comments[cs.raw_id])}">${len(cs_comments[cs.raw_id])}<i class="icon-comment-discussion"></i>
</a>
%endif
%for book in cs.bookmarks:
<span class="label label-bookmark" title="${_('Bookmark %s') % book}">${h.link_to(book,h.url('changeset_home',repo_name=repo_name,revision=cs.raw_id))}</span>
%endfor
%for tag in cs.tags:
<span class="label label-tag" title="${_('Tag %s') % tag}">${h.link_to(tag,h.url('changeset_home',repo_name=repo_name,revision=cs.raw_id))}</span>
%endfor
%if cs.bumped:
<span class="label label-bumped" title="Bumped">Bumped</span>
%endif
%if cs.divergent:
<span class="label label-divergent" title="Divergent">Divergent</span>
%endif
%if cs.extinct:
<span class="label label-extinct" title="Extinct">Extinct</span>
%endif
%if cs.unstable:
<span class="label label-unstable" title="Unstable">Unstable</span>
%endif
%if cs.phase:
<span class="label label-phase" title="Phase">${cs.phase}</span>
%endif
%if show_branch:
%for branch in cs.branches:
<span class="label label-branch" title="${_('Branch %s' % branch)}">${h.link_to(branch,h.url('changelog_home',repo_name=repo_name,branch=branch))}</span>
%endfor
%endif
</div>
</div>
</td>
</tr>
%endfor
</tbody>
</table>
<script>'use strict';
$(document).ready(function() {
$('#changesets .expand_commit').on('click',function(){
$(this).next('.mid').find('.message > div').toggleClass('hidden');
${resize_js};
});
});
</script>
</%def>
|