summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2021-06-30 09:47:23 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2021-06-30 09:47:23 -0400
commitef7b5453c1e76a66770c5da6c2770157a19327cc (patch)
tree479ab56fb569981b442c2bc6dff48002a41030ee /git.c
parent96684de3c03828c8ad5c49b5c73d129a5313ec93 (diff)
Add `get_comment_len()`.
Diffstat (limited to 'git.c')
-rw-r--r--git.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/git.c b/git.c
index d5b1661..3cb7656 100644
--- a/git.c
+++ b/git.c
@@ -180,6 +180,30 @@ int create_info_file(pull_request *pr, const char *pr_root) {
return 1;
}
+int get_comment_len(comment *comment) {
+ struct tm tm;
+ int len = format_len("title: %s\n", pr->title);
+
+ localtime_r(&comment->date, &tm);
+
+ len = format_len("id: %i\n", comment->id);
+ len += format_len("author: %s\n", comment->author);
+ len += format_len("date: ") + strftime(NULL, -1, "%c %z\n", &tm);
+
+ /* Is this comment a reply? */
+ if (comment->reply != NULL) {
+ localtime_r(&comment->reply->date, &tm);
+ len += format_len("reply-to: %i\n", comment->reply->id);
+ len += format_len("reply-author: %s\n", comment->reply->author);
+ len += format_len("reply-date: ") + strftime(NULL, -1, "%c %z\n", &tm);
+ }
+
+ len += format_len("description: %s\n\n", comment->desc);
+
+ return len;
+
+}
+
int add_comment(comment *comment, const char *pr_root) {
int len;
int buf_len;