the repository which powers this website
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
{! int cgit_refs_cmp_branch_age(const void *a, const void *b); !}
{! int cgit_refs_cmp_ref_name(const void *a, const void *b); !}
{! int cgit_refs_cmp_tag_age(const void *a, const void *b); !}

{% page cgit_print_refs %}
{! page_start(); !}
{! repo_header(); !}
		<main class="max-w-7xl mx-auto py-4">{# Main content #}
{! repo_description_panel(); !}
{! repo_summary_bar(); !}
			{% if !ctx.qry.path || starts_with(ctx.qry.path, "heads") %}
			{!
				struct reflist list;
				list.refs = NULL;
				list.alloc = list.count = 0;
				refs_for_each_branch_ref(get_main_ref_store(the_repository), cgit_refs_cb, &list);
				qsort(list.refs, list.count, sizeof(*list.refs), cgit_refs_cmp_branch_age);
				if (ctx.repo->branch_sort == 0) {
					qsort(list.refs, list.count, sizeof(*list.refs), cgit_refs_cmp_ref_name);
				}
			!}
			<div class="grid grid-cols-1 border border-[#333A45] rounded-md divide-y divide-[#333A45]">
				{# Branches list #}
				<div class="rounded-t-md bg-[#262F3F] px-3 py-2 font-semibold text-sm">
					Branches
				</div>
				{% for int i = 0; i < list.count; i++ %}
				{! struct refinfo *ref = list.refs[i]; !}
				{! struct commitinfo *info = ref->commit; !}
				{! char *name = (char *)ref->refname; !}
				{! if (!info) { continue; } !}
				<div class="px-3 py-2 flex">
					<div>
						{# Branch info #}
						<div><a href="{! cgit_shared_repolink_url(NULL, name, NULL); !}" class="text-[#73D0FF] hover:text-[#4CB3FF] hover:underline">{{ name }}</a></div>
						{% if ref->object->type == OBJ_COMMIT %}
						<div class="text-sm text-[#a3a29c] flex gap-x-1">
							{{ info->subject }} &middot; Updated {! cgit_print_age_themed(info->committer_date, info->committer_tz, TM_MONTH * 12); !}
							<img class="gravatar" src="{! gravatar_url(info->author_email); !}?s=24" class="mt-[-0.2rem]">
							{{ info->author }}
						</div>
						{% endif %}
					</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_reporevlink_url("diff", ctx.qry.head, name, NULL); !}&id2={{ ctx.qry.head|urlencode }}" class="py-1.5 px-3 self-center text-[#a3a29c] bg-[#262F3F] border border-[#333A45] rounded-md hover:bg-[#333A45]">
						Compare
					</a>
					{% endif %}
				</div>
				{% endfor %}
			</div>
			{! cgit_free_reflist_inner(&list); !}
			{% endif %}
			{% if !ctx.qry.path || starts_with(ctx.qry.path, "tags") %}
			{!
				struct reflist list;
				list.refs = NULL;
				list.alloc = list.count = 0;
				refs_for_each_tag_ref(get_main_ref_store(the_repository), cgit_refs_cb, &list);
			!}
			{% if list.count > 0 %}
			{! qsort(list.refs, list.count, sizeof(*list.refs), cgit_refs_cmp_tag_age); !}
			<div class="grid grid-cols-1 border border-[#333A45] rounded-md divide-y divide-[#333A45] mt-4">
				{# Tags list #}
				<div class="rounded-t-md bg-[#262F3F] px-3 py-2 font-semibold text-sm">
					Tags
				</div>
				{% for int i = 0; i < list.count; i++ %}
				{!
					struct refinfo *ref = list.refs[i];
					struct tag *tag = NULL;
					struct taginfo *info = NULL;
					char *name = (char *)ref->refname;
					struct object *obj = ref->object;
					
					if (obj->type == OBJ_TAG) {
						tag = (struct tag *)obj;
						obj = tag->tagged;
						info = ref->tag;
						if (!info) { continue; }
					}
				!}
				<div class="px-3 py-2">
					<div><a href="{! cgit_shared_repolink_url(NULL, name, NULL); !}" class="text-[#73D0FF] hover:text-[#4CB3FF] hover:underline">{{ name }}</a></div>
					{% if info && (info->tagger_date > 0 || info->tagger) %}
					<div class="text-sm text-[#a3a29c] flex gap-x-1">
						{% if info->tagger_date > 0 %}
						Updated {! cgit_print_age_themed(info->tagger_date, info->tagger_tz, TM_MONTH * 12); !}
						{% endif %}
						{% if info->tagger %}
						<img class="gravatar" src="{! gravatar_url(info->tagger_email); !}?s=24" class="mt-[-0.2rem]">
						{{ info->tagger }}
						{% endif %}
					</div>
					{% elif ref->object->type == OBJ_COMMIT %}
					<div class="text-sm text-[#a3a29c] flex gap-x-1">
						Updated {! cgit_print_age_themed(ref->commit->commit->date, 0, TM_MONTH * 12); !}
						<img class="gravatar" src="{! gravatar_url(ref->commit->author_email); !}?s=24" class="mt-[-0.2rem]">
						{{ ref->commit->author }}
					</div>
					{% endif %}
				</div>
				{% endfor %}
			</div>
			{! cgit_free_reflist_inner(&list); !}
			{% endif %}{# if list.count > 0 #}
			{% endif %}{# if !ctx.qry.path || starts_with(ctx.qry.path, "tags") #}
		</main>
{! page_end(); !}
{% endpage %}