diff options
-rw-r--r-- | git.c | 15 | ||||
-rw-r--r-- | git.h | 5 |
2 files changed, 18 insertions, 2 deletions
@@ -166,6 +166,21 @@ static linked_list *parse_dsv_str(const char *str, const char *delm) { return tail; } +int parse_remote_branch(void *ctx, void *ret, const keyword *key, keyword_val val) { + if (key->type != TYPE_STRING) { + if (key->offsets[0] == offsetof(pull_request, branch)) { + if (key->offsets[1] == offsetof(git_branch, name) || key->offsets[1] == offsetof(git_branch, repo)) { + pull_request *pr = (pull_request *)ret; + if (pr->branch == NULL) { + pr->branch = calloc(1, sizeof(git_branch)); + } + return 0; + } + } + } + return -1; +} + int parse_patch_list(void *ctx, void *ret, const keyword *key, keyword_val val) { /* Do we actually have a "patches" keyword? */ if (key->type == TYPE_STRING) { @@ -57,6 +57,7 @@ extern pull_request *get_pull_request(index_t *idx, const char *root, const char extern int add_comment(comment *comment, const char *pr_root); extern int create_pull_request_dir(pull_request *pr, index_t *idx, const char *root, const char *repo); +int parse_remote_branch(void *ctx, void *ret, const keyword *key, keyword_val val); int parse_patch_list(void *ctx, void *ret, const keyword *key, keyword_val val); int parse_comment_reply(void *ctx, void *ret, const keyword *key, keyword_val val); @@ -67,8 +68,8 @@ static const keyword *info_keywords[] = { &(const keyword){"date", "Date of Pull Request's creation.", "%a %b %e %H:%M:%S %Y %z", TYPE_TIME, offset_list(offsetof(pull_request, date)), NULL}, &(const keyword){"description", "Description of Pull Request.", NULL, TYPE_STRING, offset_list(offsetof(pull_request, desc)), NULL}, &(const keyword){"type", "Type of Pull Request (0 = patch files, 1 = remote repo).", NULL, TYPE_INT, offset_list(offsetof(pull_request, pr_type)), NULL}, - &(const keyword){"branch", "Branch of remote repo.", NULL, TYPE_STRING, offset_list(offsetof(pull_request, branch), offsetof(git_branch, name)), NULL}, - &(const keyword){"repo", "URL of remote repo.", NULL, TYPE_STRING, offset_list(offsetof(pull_request, branch), offsetof(git_branch, repo)), NULL}, + &(const keyword){"branch", "Branch of remote repo.", NULL, TYPE_STRING, offset_list(offsetof(pull_request, branch), offsetof(git_branch, name)), parse_remote_branch}, + &(const keyword){"repo", "URL of remote repo.", NULL, TYPE_STRING, offset_list(offsetof(pull_request, branch), offsetof(git_branch, repo)), parse_remote_branch}, &(const keyword){"patches", "Patch file(s) of Pull Request.", NULL, TYPE_STRING, offset_list(offsetof(pull_request, patches), offsetof(file, name)), parse_patch_list}, NULL, }; |