Fix behaviour of tree view when viewing root of commit

This commit is contained in:
RunasSudo 2025-05-15 14:57:45 +10:00
parent 8f023f452d
commit bc551c0d18
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
3 changed files with 16 additions and 10 deletions

View File

@ -31,7 +31,7 @@
{# Heroicons micro list-bullet #} {# Heroicons micro list-bullet #}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4 self-center text-gray-500"><path d="M3 4.75a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM6.25 3a.75.75 0 0 0 0 1.5h7a.75.75 0 0 0 0-1.5h-7ZM6.25 7.25a.75.75 0 0 0 0 1.5h7a.75.75 0 0 0 0-1.5h-7ZM6.25 11.5a.75.75 0 0 0 0 1.5h7a.75.75 0 0 0 0-1.5h-7ZM4 12.25a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM3 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" /></svg> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4 self-center text-gray-500"><path d="M3 4.75a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM6.25 3a.75.75 0 0 0 0 1.5h7a.75.75 0 0 0 0-1.5h-7ZM6.25 7.25a.75.75 0 0 0 0 1.5h7a.75.75 0 0 0 0-1.5h-7ZM6.25 11.5a.75.75 0 0 0 0 1.5h7a.75.75 0 0 0 0-1.5h-7ZM4 12.25a1 1 0 1 1-2 0 1 1 0 0 1 2 0ZM3 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" /></svg>
<span class="font-semibold self-baseline"> <span class="font-semibold self-baseline">
{% if strcmp(ctx.qry.page, "tree") == 0 && ctx.qry.oid %} {% if (strcmp(ctx.qry.page, "tree") == 0 || strcmp(ctx.qry.page, "summary") == 0) && ctx.qry.oid %}
{! short_commit_id(ctx.qry.oid); !} {! short_commit_id(ctx.qry.oid); !}
{% else %} {% else %}
{{ ctx.qry.head }} {{ ctx.qry.head }}

View File

@ -31,7 +31,7 @@
} }
!} !}
{% page cgit_print_summary %} {% block cgit_print_summary_impl %}
{! page_start(); !} {! page_start(); !}
{! repo_header(); !} {! repo_header(); !}
<main class="max-w-[1280px] mx-auto py-4">{# Main content #} <main class="max-w-[1280px] mx-auto py-4">{# Main content #}
@ -40,9 +40,11 @@
<div class="grid grid-cols-[auto_1fr_auto_auto] border border-gray-300 rounded-md mb-4"> <div class="grid grid-cols-[auto_1fr_auto_auto] border border-gray-300 rounded-md mb-4">
{# Latest commit panel (specify rounded-t-md so background does not cover border) #} {# Latest commit panel (specify rounded-t-md so background does not cover border) #}
{! {!
// Get latest commit char *hex = ctx.qry.oid;
if (!hex) { hex = ctx.qry.head; }
struct object_id oid; struct object_id oid;
if (repo_get_oid(the_repository, ctx.qry.head, &oid)) { if (repo_get_oid(the_repository, hex, &oid)) {
die("Bad object id"); die("Bad object id");
} }
struct commit *commit = lookup_commit_reference(the_repository, &oid); struct commit *commit = lookup_commit_reference(the_repository, &oid);
@ -102,4 +104,8 @@
{% endif %} {% endif %}
</main> </main>
{! page_end(); !} {! page_end(); !}
{% endblock %}
{% page cgit_print_summary %}
{! cgit_print_summary_impl(); !}
{% endpage %} {% endpage %}

View File

@ -151,7 +151,7 @@
{% page cgit_print_tree %} {% page cgit_print_tree %}
{! {!
// Redirect to summary page if no subdirectory // Redirect to summary page if no subdirectory
if (!ctx.qry.path) { return cgit_print_summary(); } if (!ctx.qry.path) { return cgit_print_summary_impl(); }
!} !}
{! page_start(); !} {! page_start(); !}
{! repo_header(); !} {! repo_header(); !}