diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-26 14:17:51 -0400 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-06-26 14:17:51 -0400 |
commit | 0be4dd7fdae48923df2d2f1c3525269bc948a16d (patch) | |
tree | ca2ef95e7a906b950718d631ba7d574f9f5eb288 /git.c | |
parent | 30afc5de57b24a7fab895e0b421b2ca754cfb82c (diff) |
Added `get_info_len()`.
This function gets the length of the contents of the
info file to make.
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -68,6 +68,31 @@ pull_request *get_pull_request(int id, const char *root) { } +int get_info_len(pull_request *pr) { + struct tm tm; + int len = format_len("title: %s\n", pr->title); + + localtime_r(&pr->date, &tm); + + len += format_len("author: %s\n", pr->author); + len += format_len("date: ") + strftime(NULL, -1, "%c %z\n", &tm); + len += format_len("description: %s\n", pr->desc); + len += format_len("type: %i\n", pr->pr_type); + + /* Is this PR using a remote branch? */ + if (pr->pr_type) { + len += format_len("branch: %s\n", pr->branch->name); + len += format_len("repo: %s", pr->branch->repo); + } else { + len += format_len("patches:"); + for (int i = 0; pr->patches[i] != NULL; i++) { + len += format_len(" %s", pr->patches[i]->name); + } + } + return len; + +} + int create_info(pull_request *pr, const char *pr_dir) { int len; int buf_len; |