List for cgit developers and users
 help / color / mirror / Atom feed
* Feature Request: show ages in tree view
@ 2016-10-30 12:22 
  2016-11-24 18:56 ` john
  0 siblings, 1 reply; 2+ messages in thread
From:  @ 2016-10-30 12:22 UTC (permalink / raw)


Hello,

i want to see when a file or tree was last changed when i'm watching the tree of a repository.
I've tried to implement it myself, but it seems i can't, though i have something to illustrate what i mean.

diff --git a/ui-tree.c b/ui-tree.c
index b310242..78e5676 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -232,6 +232,10 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base,
 	enum object_type type;
 	unsigned long size = 0;
 
+	struct commitinfo *info;
+	struct commit *commit;
+	unsigned char c_sha1[20];
+
 	name = xstrdup(pathname);
 	strbuf_addf(&fullpath, "%s%s%s", ctx.qry.path ? ctx.qry.path : "",
 		    ctx.qry.path ? "/" : "", name);
@@ -247,6 +251,10 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base,
 		}
 	}
 
+	get_sha1(walk_tree_ctx->curr_rev, c_sha1);
+	commit = lookup_commit_reference(c_sha1);
+	info = cgit_parse_commit(commit);
+
 	html("<tr><td class='ls-mode'>");
 	cgit_print_filemode(mode);
 	html("</td><td>");
@@ -255,6 +263,8 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base,
 	} else if (S_ISDIR(mode)) {
 		write_tree_link(sha1, name, walk_tree_ctx->curr_rev,
 				&fullpath);
+		html("</td><td style='text-align:right'>");
+		cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2);
 	} else {
 		char *ext = strrchr(name, '.');
 		strbuf_addstr(&class, "ls-blob");
@@ -262,6 +272,8 @@ static int ls_item(const unsigned char *sha1, struct strbuf *base,
 			strbuf_addf(&class, " %s", ext + 1);
 		cgit_tree_link(name, NULL, class.buf, ctx.qry.head,
 			       walk_tree_ctx->curr_rev, fullpath.buf);
+		html("</td><td style='text-align:right'>");
+		cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2);
 	}
 	htmlf("</td><td class='ls-size'>%li</td>", size);
 
@@ -289,6 +301,7 @@ static void ls_head(void)
 	html("<tr class='nohover'>");
 	html("<th class='left'>Mode</th>");
 	html("<th class='left'>Name</th>");
+	html("<th class='right'>Age</th>");
 	html("<th class='right'>Size</th>");
 	html("<th/>");
 	html("</tr>\n");


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-24 18:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-30 12:22 Feature Request: show ages in tree view 
2016-11-24 18:56 ` john

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).