1#pragma once
2
3/****************************************************************************************
4 ** GitQlient is an application to manage and operate one or several Git repositories. With
5 ** GitQlient you will be able to add commits, branches and manage all the options Git provides.
6 ** Copyright (C) 2021 Francesc Martinez
7 **
8 ** LinkedIn: www.linkedin.com/in/cescmm/
9 ** Web: www.francescmm.com
10 **
11 ** This program is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU Lesser General Public
13 ** License as published by the Free Software Foundation; either
14 ** version 2 of the License, or (at your option) any later version.
15 **
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** Lesser General Public License for more details.
20 **
21 ** You should have received a copy of the GNU Lesser General Public
22 ** License along with this library; if not, write to the Free Software
23 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 ***************************************************************************************/
25
26#include <Issue.h>
27#include <Commit.h>
28
29#include <QMap>
30
31namespace GitServer
32{
33
34struct PullRequest : public Issue
35{
36 PullRequest() = default;
37
38 PullRequest(const Issue &issue)
39 {
40 number = issue.number;
41 title = issue.title;
42 body = issue.body;
43 milestone = issue.milestone;
44 labels = issue.labels;
45 creator = issue.creator;
46 assignees = issue.assignees;
47 url = issue.url;
48 creation = issue.creation;
49 comments = issue.comments;
50 }
51
52 struct HeadState
53 {
54 enum class State
55 {
56 Failure,
57 Success,
58 Pending
59 };
60
61 struct Check
62 {
63 QString description;
64 QString state;
65 QString url;
66 QString name;
67 };
68
69 QString sha {};
70 QString state {};
71 State eState {};
72 QVector<Check> checks {};
73 };
74
75 QString head {};
76 QString headRepo {};
77 QString headUrl {};
78 QString base {};
79 QString baseRepo {};
80 bool maintainerCanModify = true;
81 bool draft = false;
82 int id = 0;
83 QString url {};
84 HeadState state {};
85 QMap<int, Review> reviews {};
86 QVector<CodeReview> reviewComment {};
87 int reviewCommentsCount = 0;
88 int commitCount = 0;
89 int additions = 0;
90 int deletions = 0;
91 int changedFiles = 0;
92 bool merged = false;
93 bool mergeable = false;
94 bool rebaseable = false;
95 QString mergeableState {};
96 QVector<Commit> commits {};
97
98 QJsonObject toJson() const
99 {
100 QJsonObject object;
101
102 object.insert("title", title);
103 object.insert("head", head);
104 object.insert("base", base);
105 object.insert("body", body.toStdString().c_str());
106 object.insert("maintainer_can_modify", maintainerCanModify);
107 object.insert("draft", draft);
108
109 return object;
110 }
111
112 bool isValid() const { return !title.isEmpty(); }
113
114public:
115 int getCommits() const;
116 void setCommits(int value);
117};
118
119}
120