summaryrefslogtreecommitdiff
path: root/git.h
blob: 351b92d4e34e61408abc6febe080babee5b86150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef GIT_H
#define GIT_H

#include <git2.h>
#include <stdint.h>
#include <time.h>

typedef struct git_repo git_repo;
typedef struct pull_request pull_request;
typedef struct file file;
typedef struct comment comment;
typedef struct git_branch git_branch;

struct git_repo {
	git_repo *next;
	git_repository *repo;
};

struct file {
	char *name;	/* Name of file. */
	char *buf;	/* Buffer containing contents of file. */
};

struct comment {
	char *author;	/* Author of comment. */
	char *desc;	/* Description/Contents of comment. */
	time_t date;	/* Date of creation. */
	int id;		/* Comment ID. */
	comment *reply;	/* Comment that is being replied to. */
};

struct git_branch {
	char *name;	/* Name of branch. */
	char *repo;	/* Path, or URL to local, or remote repository. */
};

struct pull_request {
	char *title;			/* Title of the pull request. */
	char *desc;			/* Description of the pull request. */
	char *author;			/* Author of the pull request. */
	comment **comments;		/* Comments of this pull reuqest. */
	time_t date;			/* Date of creation. */
	uint8_t pr_type;		/* Type of pull request. (0 = individual commit patches, 1 = remote branch) */
	union {
		file **patches;		/* Patch files of pull request. */
		git_branch *branch;	/* Branch of pull request. */
	};
	git_branch *merge_branch;	/* Branch to merge pull request with. */
};

extern void cleanup_git(git_repository **repos);
extern git_repository **init_git(config *cfg);
extern int add_comment(comment *comment, const char *pr_root);
extern int create_pull_request_dir(pull_request *pr, int id, const char *root);

#endif