From mboxrd@z Thu Jan 1 00:00:00 1970 From: cgit at ml.breakpoint.cc (cgit at ml.breakpoint.cc) Date: Thu, 21 Jun 2012 09:09:48 +0200 Subject: [PATCH 3/3] summary: Add tag head line in the dowload section In-Reply-To: <1340262588-24202-1-git-send-email-cgit@ml.breakpoint.cc> References: <1340262588-24202-1-git-send-email-cgit@ml.breakpoint.cc> Message-ID: <1340262588-24202-3-git-send-email-cgit@ml.breakpoint.cc> From: Sebastian Andrzej Siewior If the downloads are disabled one gets only ugly "commit sha1". With downloads enabled you see the file name with different extensions a few times. This patches changes it a little. Instead of printing the hash number it prints the first line of the tag i.e. the head line / commit subject if available. With downloads enabled it prints additionally the extension of the archive type (i.e. .tar, .tar.xz) next to it. Signed-off-by: Sebastian Andrzej Siewior --- ui-refs.c | 7 ++++--- ui-tag.c | 34 ++++++++++++++++++++++++++++++++++ ui-tag.h | 1 + 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/ui-refs.c b/ui-refs.c index caddfbc..9336703 100644 --- a/ui-refs.c +++ b/ui-refs.c @@ -9,6 +9,7 @@ #include "cgit.h" #include "html.h" #include "ui-shared.h" +#include "ui-tag.h" static int header; @@ -119,7 +120,7 @@ static void print_tag_downloads(const struct cgit_repo *repo, const char *ref) if (!(repo->snapshots & f->bit)) continue; filename = fmt("%s%s", ref, f->suffix); - cgit_snapshot_link(filename, NULL, NULL, NULL, NULL, filename); + cgit_snapshot_link(f->suffix, NULL, NULL, NULL, NULL, filename); html("  "); } } @@ -137,10 +138,10 @@ static int print_tag(struct refinfo *ref) html(""); cgit_tag_link(name, NULL, NULL, ctx.qry.head, name); html(""); + cgit_print_tag_subject(name); + html(" "); if (ctx.repo->snapshots && (tag->tagged->type == OBJ_COMMIT)) print_tag_downloads(ctx.repo, name); - else - cgit_object_link(tag->tagged); html(""); if (info->tagger) html(info->tagger); diff --git a/ui-tag.c b/ui-tag.c index 39e4cb8..18c3361 100644 --- a/ui-tag.c +++ b/ui-tag.c @@ -38,6 +38,40 @@ void print_download_links(char *revname) html(""); } +void cgit_print_tag_subject(char *revname) +{ + unsigned char sha1[20]; + struct object *obj; + struct taginfo *info; + struct tag *tag; + char *p; + size_t len; + + if (get_sha1(fmt("refs/tags/%s", revname), sha1)) { + cgit_print_error(fmt("Bad tag reference: %s", revname)); + return; + } + obj = parse_object(sha1); + if (!obj) { + cgit_print_error(fmt("Bad object id: %s", sha1_to_hex(sha1))); + return; + } + + tag = lookup_tag(sha1); + if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) { + cgit_print_error(fmt("Bad tag object: %s", revname)); + return; + } + p = strchr(info->msg, '\n'); + if (p) + *p = '\0'; + len = strlen(info->msg); + if (len > 74) + info->msg[74] = '\0'; + + html_txt(info->msg); +} + void cgit_print_tag(char *revname) { unsigned char sha1[20]; diff --git a/ui-tag.h b/ui-tag.h index d295cdc..352e0fd 100644 --- a/ui-tag.h +++ b/ui-tag.h @@ -2,5 +2,6 @@ #define UI_TAG_H extern void cgit_print_tag(char *revname); +void cgit_print_tag_subject(char *revname); #endif /* UI_TAG_H */ -- 1.7.2.5