Add compare button to branches page

This commit is contained in:
RunasSudo 2025-05-15 14:57:44 +10:00
parent 7f5688dc7e
commit 91ce363f0e
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -29,7 +29,9 @@
{! struct commitinfo *info = ref->commit; !} {! struct commitinfo *info = ref->commit; !}
{! char *name = (char *)ref->refname; !} {! char *name = (char *)ref->refname; !}
{! if (!info) { continue; } !} {! if (!info) { continue; } !}
<div class="px-3 py-2"> <div class="px-3 py-2 flex">
<div>
{# Branch info #}
<div><a href="{! cgit_shared_repolink_url(NULL, name, NULL); !}" class="text-blue-500 hover:text-blue-600 hover:underline">{{ name }}</a></div> <div><a href="{! cgit_shared_repolink_url(NULL, name, NULL); !}" class="text-blue-500 hover:text-blue-600 hover:underline">{{ name }}</a></div>
{% if ref->object->type == OBJ_COMMIT %} {% if ref->object->type == OBJ_COMMIT %}
<div class="text-sm text-gray-500 flex gap-x-1"> <div class="text-sm text-gray-500 flex gap-x-1">
@ -39,6 +41,13 @@
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% if strcmp(name, ctx.qry.head) %}{# Only show compare button if not equal to current branch #}
<div class="flex-1"></div>
<a href="{! cgit_shared_repolink_url_with_delimiter("diff", ctx.qry.head, NULL); !}id={{ name|urlencode }}&id2={{ ctx.qry.head|urlencode }}" class="py-1.5 px-3 self-center text-gray-500 bg-gray-50 border border-gray-300 rounded-md hover:bg-gray-100">
Compare
</a>
{% endif %}
</div>
{% endfor %} {% endfor %}
</div> </div>
{! cgit_free_reflist_inner(&list); !} {! cgit_free_reflist_inner(&list); !}