mygit

[UNMAINTAINED] A cgit/webgit alternative, written in Rust
Log | Files | Refs | README | LICENSE

commit d6157cbd3b083204de5250b9ff699d0f6c1f706f
parent bd2c7120fc44ee6771a08fbb7cbee925c1ef2153
Author: Johann150 <johann@qwertqwefsday.eu>
Date:   Tue, 29 Jun 2021 11:43:04 +0200

list submodules without panicking

Instead of panicking when a submodule is part of a listing, only
show a very bare row just containing the permissions and name.

Diffstat:
Mtemplates/tree.html | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/templates/tree.html b/templates/tree.html @@ -14,16 +14,24 @@ <td class="permissions"> {{ entry.filemode()|unix_perms }} </td> + {% let obj = entry.to_object(repo) %} + {% if obj.is_ok() %} + {% let o = obj.unwrap() %} <td class="filename"> <a href="/{{repo|repo_name|urlencode_strict}}/tree/{{ spec }}/item/{{path.join(entry.name().unwrap()).to_string_lossy()}}"> - {{ entry.name().unwrap() }}{% if entry.to_object(repo).unwrap().as_tree().is_some() %}/{% endif %}</a> + {{ entry.name().unwrap() }}{% if o.as_tree().is_some() %}/{% endif %}</a> </td> <td class="filesize"> - {% let obj = entry.to_object(repo).unwrap() %} - {% if obj.as_blob().is_some() %} - {{ entry.to_object(repo).unwrap().into_blob().unwrap().content().len()|filesizeformat }} + {% if o.as_blob().is_some() %} + {{ o.into_blob().unwrap().content().len()|filesizeformat }} {% endif %} </td> + {% else %} + <td class="filename"> + {{ entry.name().unwrap() }} + </td> + <td class="filesize"></td> + {% endif %} </tr> {% endfor %} </table>