-rw-r--r-- | ui-summary.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ui-summary.c b/ui-summary.c index c684628..43582da 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -1,36 +1,53 @@ /* ui-summary.c: functions for generating repo summary page * * Copyright (C) 2006 Lars Hjemli * * Licensed under GNU General Public License v2 * (see COPYING for full license text) */ #include "cgit.h" static int header; +static int cmp_tag_age(void *a, void *b) +{ + struct refinfo *r1 = *(struct refinfo **)a; + struct refinfo *r2 = *(struct refinfo **)b; + + if (r1->tag->tagger_date != 0 && r2->tag->tagger_date != 0) + return r2->tag->tagger_date - r1->tag->tagger_date; + + if (r1->tag->tagger_date == 0 && r2->tag->tagger_date == 0) + return 0; + + if (r1 == 0) + return +1; + + return -1; +} + static void cgit_print_branch(struct refinfo *ref) { struct commit *commit; struct commitinfo *info; char *name = (char *)ref->refname; commit = lookup_commit(ref->object->sha1); // object is not really parsed at this point, because of some fallout // from previous calls to git functions in cgit_print_log() commit->object.parsed = 0; if (commit && !parse_commit(commit)){ info = cgit_parse_commit(commit); html("<tr><td>"); cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0); html("</td><td>"); cgit_print_age(commit->date, -1, NULL); html("</td><td>"); html_txt(info->author); html("</td><td>"); cgit_commit_link(info->subject, NULL, NULL, name, NULL); html("</td></tr>\n"); cgit_free_commitinfo(info); } else { html("<tr><td>"); @@ -135,48 +152,49 @@ static void cgit_print_branches() html("<tr class='nohover'><th class='left'>Branch</th>" "<th class='left'>Idle</th>" "<th class='left'>Author</th>" "<th class='left'>Head commit</th></tr>\n"); list.refs = NULL; list.alloc = list.count = 0; for_each_branch_ref(cgit_refs_cb, &list); for(i=0; i<list.count; i++) cgit_print_branch(list.refs[i]); } static void cgit_print_tags() { struct reflist list; int i; header = 0; list.refs = NULL; list.alloc = list.count = 0; for_each_tag_ref(cgit_refs_cb, &list); if (list.count == 0) return; + qsort(list.refs, list.count, sizeof(*list.refs), cmp_tag_age); print_tag_header(); for(i=0; i<list.count; i++) print_tag(list.refs[i]); } static void cgit_print_archives() { header = 0; for_each_ref(cgit_print_archive_cb, NULL); if (header) html("</table>"); } void cgit_print_summary() { html("<div id='summary'>"); cgit_print_archives(); html("<h2>"); html_txt(cgit_repo->name); html(" - "); html_txt(cgit_repo->desc); html("</h2>"); if (cgit_repo->readme) html_include(cgit_repo->readme); |