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 <[email protected]>
---
 ui-refs.c |  5 +++--
 ui-tag.c  | 31 +++++++++++++++++++++++++++++++
 ui-tag.h  |  1 +
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/ui-refs.c b/ui-refs.c
index 147b665..e0fd120 100644
--- a/ui-refs.c
+++ b/ui-refs.c
@@ -10,6 +10,7 @@
 #include "ui-refs.h"
 #include "html.h"
 #include "ui-shared.h"
+#include "ui-tag.h"
 
 static int cmp_age(int age1, int age2)
 {
@@ -150,10 +151,10 @@ static int print_tag(struct refinfo *ref)
        html("<tr><td>");
        cgit_tag_link(name, NULL, NULL, ctx.qry.head, name);
        html("</td><td>");
+       cgit_print_tag_subject(name);
+       html(" ");
        if (ctx.repo->snapshots && (obj->type == OBJ_COMMIT))
                print_tag_downloads(ctx.repo, name);
-       else
-               cgit_object_link(obj);
        html("</td><td>");
        if (info) {
                if (info->tagger) {
diff --git a/ui-tag.c b/ui-tag.c
index c1d1738..ef1d320 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -39,6 +39,37 @@ static void print_download_links(char *revname)
        html("</td></tr>");
 }
 
+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))
+               return;
+
+       obj = parse_object(sha1);
+       if (!obj)
+               return;
+
+       tag = lookup_tag(sha1);
+       if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag)))
+               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);
+       free(info);
+}
+
 void cgit_print_tag(char *revname)
 {
        struct strbuf fullref = STRBUF_INIT;
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.8.5.2

_______________________________________________
CGit mailing list
[email protected]
http://lists.zx2c4.com/mailman/listinfo/cgit

Reply via email to