[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cgit
Subject:    [PATCH] Add trailing ellipsis to commits with body content
From:       Kevin Morris <kevr.gtalk () gmail ! com>
Date:       2019-02-23 6:03:10
Message-ID: 20190223060310.8736-1-kevr.gtalk () gmail ! com
[Download RAW message or body]

Add ellipsis to each short commit subject where its body contains
some user-input data (excluding vanilla Signed-off-by -sm messages)

Signed-off-by: Kevin Morris <kevr.gtalk@gmail.com>
---
 ui-log.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/ui-log.c b/ui-log.c
index 3bcb657..202aa55 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -237,8 +237,25 @@ static void print_commit(struct commit *commit, struct rev_info *revs)
 			strlcpy(info->subject + i, wrap_symbol, subject_len - i + 1);
 		}
 	}
-	cgit_commit_link(info->subject, NULL, NULL, ctx.qry.head,
+
+	char *subject = NULL;
+	size_t subject_len = strlen(info->subject);
+	char *msg = info->msg;
+	const char signed_off[] = "Signed-off-by";
+	if(strncmp(signed_off, msg, strlen(signed_off)) == 0) {
+		subject = calloc(subject_len + 2, sizeof(char));
+		snprintf(subject, subject_len + 1, "%s", info->subject);
+	} else if(strlen(info->msg) > 0) {
+		// Ellipsis here
+		subject = calloc(subject_len + 5 + 1, sizeof(char));
+		snprintf(subject, subject_len + 5, "%s ...", info->subject); 
+	} else {
+		subject = calloc(subject_len + 2, sizeof(char));
+		snprintf(subject, subject_len + 1, "%s", info->subject);
+	}
+	cgit_commit_link(subject, NULL, NULL, ctx.qry.head,
 			 oid_to_hex(&commit->object.oid), ctx.qry.vpath);
+	free(subject);
 	show_commit_decorations(commit);
 	html("</td><td>");
 	cgit_open_filter(ctx.repo->email_filter, info->author_email, "log");
-- 
2.20.1

_______________________________________________
CGit mailing list
CGit@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/cgit
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic