diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2022-08-05 21:50:04 -0300 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2022-08-05 21:50:04 -0300 |
commit | 40a2464cb16e318b17723a72cef857842ee16c91 (patch) | |
tree | 7134cfc50bf2988ad1b0f85a6cc97e56659b4fcf | |
parent | 2898adab6fde190d09f87cac58862c67ee193559 (diff) |
git: Add `get_keyword_cb` getter callbacks
-rw-r--r-- | git.c | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -377,6 +377,34 @@ pull_request *get_pull_request(index_t *idx, const char *root, const char *repo) } } +int has_remote_branch(void *ctx, void *data, const keyword *key, keyword_val *val) { + pull_request *pr = (pull_request *)data; + return (pr->pr_type) ? 0 : -1; +} + +int get_patch_list(void *ctx, void *data, const keyword *key, keyword_val *val) { + pull_request *pr = (pull_request *)data; + + if (key->type == TYPE_STRING && !pr->pr_type && pr->patches != NULL) { + int len = 0; + char *tmp; + + for (int i = 0; pr->patches[i] != NULL; i++) { + len += format_len("% *s", !i, pr->patches[i]->name); + } + + val->str = calloc(len+1, sizeof(char)); + tmp = val->str; + + for (int i = 0; pr->patches[i] != NULL; i++) { + tmp += sprintf(tmp, "%*s", !i, pr->patches[i]->name); + } + return 2; + } else { + return -1; + } +} + int get_info_len(pull_request *pr) { struct tm tm; int len = format_len("title: %s\n", pr->title); @@ -489,6 +517,26 @@ int create_info_file(pull_request *pr, const char *pr_root) { return 1; } +int get_comment_reply(void *ctx, void *data, const keyword *key, keyword_val *val) { + comment *comm = (comment *)data; + + if (comm->reply != NULL) { + /* Which keyword do we have? */ + switch (key->type) { + /* reply-to */ + case TYPE_INT : val->i = comm->reply->id; break; + /* reply-author */ + case TYPE_STRING: val->str = comm->reply->author; break; + /* reply-date */ + case TYPE_TIME : val->t = comm->reply->date; break; + default : return -1; break; + } + return 1; + } else { + return -1; + } +} + int get_comment_len(comment *comment) { struct tm tm; int len = format_len("id: %i\n", comment->id); |