List for cgit developers and users
 help / color / mirror / Atom feed
From: cgit at ml.breakpoint.cc (cgit at ml.breakpoint.cc)
Subject: [PATCH 3/3] summary: Add tag head line in the dowload section
Date: Thu, 21 Jun 2012 09:09:48 +0200	[thread overview]
Message-ID: <1340262588-24202-3-git-send-email-cgit@ml.breakpoint.cc> (raw)
In-Reply-To: <1340262588-24202-1-git-send-email-cgit@ml.breakpoint.cc>

From: Sebastian Andrzej Siewior <sebastian at breakpoint.cc>

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 <sebastian at breakpoint.cc>
---
 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("&nbsp;&nbsp;");
 	}
 }
@@ -137,10 +138,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 && (tag->tagged->type == OBJ_COMMIT))
 			print_tag_downloads(ctx.repo, name);
-		else
-			cgit_object_link(tag->tagged);
 		html("</td><td>");
 		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("</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)) {
+		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





      parent reply	other threads:[~2012-06-21  7:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-21  7:09 [PATCH 1/3] snapshots: Don't allow sneaked in snapshots requests cgit
2012-06-21  7:09 ` [PATCH 2/3] cache: use sendfile() instead of a pair of read() + write() cgit
2012-06-23 10:27   ` mathstuf
2012-06-23 19:25     ` [PATCH 2/3 v2] " cgit
2012-06-21  7:09 ` cgit [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340262588-24202-3-git-send-email-cgit@ml.breakpoint.cc \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).