Refactor short_commit_id function
This commit is contained in:
parent
4358943af4
commit
836f4cd06d
@ -1,4 +1,4 @@
|
||||
{! static int get_num_commits(); static int get_num_branches(); static int get_num_tags(); !}
|
||||
{! static int get_num_commits(); static int get_num_branches(); static int get_num_tags(); static void short_commit_id(char *hex); !}
|
||||
|
||||
{% block page_start %}
|
||||
<!DOCTYPE html>
|
||||
@ -30,7 +30,13 @@
|
||||
<a href="{! cgit_shared_repolink_url("refs", ctx.qry.head, NULL); !}" class="flex gap-x-1.5 py-1.5 px-3 bg-gray-50 border border-gray-300 rounded-md hover:bg-gray-100">
|
||||
{# 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>
|
||||
<span class="font-semibold self-baseline">{{ ctx.qry.head }}</span>
|
||||
<span class="font-semibold self-baseline">
|
||||
{% if strcmp(ctx.qry.page, "tree") == 0 && ctx.qry.oid %}
|
||||
{! short_commit_id(ctx.qry.oid); !}
|
||||
{% else %}
|
||||
{{ ctx.qry.head }}
|
||||
{% endif %}
|
||||
</span>
|
||||
{# Heroicons micro chevron-down #}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4 self-center text-gray-500"><path fill-rule="evenodd" d="M4.22 6.22a.75.75 0 0 1 1.06 0L8 8.94l2.72-2.72a.75.75 0 1 1 1.06 1.06l-3.25 3.25a.75.75 0 0 1-1.06 0L4.22 7.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" /></svg>
|
||||
</a>
|
||||
@ -184,6 +190,13 @@
|
||||
cgit_free_reflist_inner(&list);
|
||||
return num_tags;
|
||||
}
|
||||
|
||||
static void short_commit_id(char *hex) {
|
||||
char short_commit_id[8];
|
||||
memcpy(short_commit_id, hex, 7);
|
||||
short_commit_id[7] = '\0';
|
||||
html_txt(short_commit_id);
|
||||
}
|
||||
!}
|
||||
|
||||
{!
|
||||
|
@ -39,19 +39,20 @@
|
||||
<span class="font-gray-500 text-sm">{! cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); !} ago</span>
|
||||
<div class="flex-1"></div>
|
||||
<span class="font-gray-500 text-sm">
|
||||
{! char short_commit_id[8]; !}
|
||||
{% for struct commit_list *p = commit->parents; p; p = p->next %}
|
||||
{! struct commit *parent = lookup_commit_reference(the_repository, &p->item->object.oid); !}
|
||||
{% if parent %}
|
||||
{! memcpy(short_commit_id, oid_to_hex(&p->item->object.oid), 7); !}
|
||||
{! short_commit_id[7] = '\0'; !}
|
||||
parent <a href="{! cgit_shared_repolink_url_with_delimiter("commit", ctx.qry.head, ctx.qry.vpath); !}id={{ oid_to_hex(&p->item->object.oid) }}" class="font-mono text-blue-500 hover:text-blue-600 hover:underline">{{ short_commit_id }}</a>
|
||||
parent
|
||||
<a href="{! cgit_shared_repolink_url_with_delimiter("commit", ctx.qry.head, ctx.qry.vpath); !}id={{ oid_to_hex(&p->item->object.oid) }}" class="font-mono text-blue-500 hover:text-blue-600 hover:underline">
|
||||
{! short_commit_id(oid_to_hex(&p->item->object.oid)); !}
|
||||
</a>
|
||||
·
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{! memcpy(short_commit_id, oid_to_hex(&commit->object.oid), 7); !}
|
||||
{! short_commit_id[7] = '\0'; !}
|
||||
commit <a href="{! cgit_shared_repolink_url_with_delimiter("commit", ctx.qry.head, ctx.qry.vpath); !}id={{ oid_to_hex(&commit->object.oid) }}" class="font-mono text-blue-500 hover:text-blue-600 hover:underline">{{ short_commit_id }}</a>
|
||||
commit
|
||||
<a href="{! cgit_shared_repolink_url_with_delimiter("commit", ctx.qry.head, ctx.qry.vpath); !}id={{ oid_to_hex(&commit->object.oid) }}" class="font-mono text-blue-500 hover:text-blue-600 hover:underline">
|
||||
{! short_commit_id(oid_to_hex(&commit->object.oid)); !}
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -36,10 +36,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-3 py-2 border-t border-gray-300 flex items-center">
|
||||
{! char short_commit_id[8]; !}
|
||||
{! memcpy(short_commit_id, oid_to_hex(&commit->object.oid), 7); !}
|
||||
{! short_commit_id[7] = '\0'; !}
|
||||
<a href="{! cgit_shared_repolink_url_with_delimiter("commit", ctx.qry.head, ctx.qry.vpath); !}id={{ oid_to_hex(&commit->object.oid) }}" class="text-sm font-mono text-gray-500 hover:text-blue-600 hover:underline">{{ short_commit_id }}</a>
|
||||
<a href="{! cgit_shared_repolink_url_with_delimiter("commit", ctx.qry.head, ctx.qry.vpath); !}id={{ oid_to_hex(&commit->object.oid) }}" class="text-sm font-mono text-gray-500 hover:text-blue-600 hover:underline">
|
||||
{! short_commit_id(oid_to_hex(&commit->object.oid)); !}
|
||||
</a>
|
||||
</div>
|
||||
<div class="px-3 py-2 border-t border-gray-300 flex items-center">
|
||||
<a href="{! cgit_shared_repolink_url_with_delimiter("tree", ctx.qry.head, ctx.qry.vpath); !}id={{ oid_to_hex(&commit->object.oid) }}" class="text-gray-500 hover:text-blue-600">
|
||||
|
@ -52,10 +52,13 @@
|
||||
<span class="font-semibold">{{ info->author }}</span>
|
||||
<a href="{! cgit_shared_repolink_url_with_delimiter("commit", ctx.qry.head, ctx.qry.vpath); !}id={{ oid_to_hex(&commit->object.oid) }}" class="ml-2 text-gray-500 hover:text-blue-600 hover:underline">{{ info->subject }}</a>
|
||||
<div class="flex-1"></div>
|
||||
{! char short_commit_id[8]; !}
|
||||
{! memcpy(short_commit_id, oid_to_hex(&commit->object.oid), 7); !}
|
||||
{! short_commit_id[7] = '\0'; !}
|
||||
<span class="text-gray-500"><a href="{! cgit_shared_repolink_url_with_delimiter("commit", ctx.qry.head, ctx.qry.vpath); !}id={{ oid_to_hex(&commit->object.oid) }}" class="font-mono hover:text-blue-600 hover:underline">{{ short_commit_id }}</a> · {! cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); !} ago</span>
|
||||
<span class="text-gray-500">
|
||||
<a href="{! cgit_shared_repolink_url_with_delimiter("commit", ctx.qry.head, ctx.qry.vpath); !}id={{ oid_to_hex(&commit->object.oid) }}" class="font-mono hover:text-blue-600 hover:underline">
|
||||
{! short_commit_id(oid_to_hex(&commit->object.oid)); !}
|
||||
</a>
|
||||
·
|
||||
{! cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); !} ago
|
||||
</span>
|
||||
</div>
|
||||
{# Files #}
|
||||
{!
|
||||
|
Loading…
x
Reference in New Issue
Block a user