pull_request.gno
1.28 Kb ยท 59 lines
1package evaluation
2
3var pullRequestStatus map[string]struct{}
4
5type PullRequest struct {
6 id int
7 name string
8 description string
9 status string // Draft, Review required, Changes requested, Approved
10 category string // bounty, chore, defect, document etc.
11}
12
13func init() {
14 pullRequestStatus = make(map[string]struct{})
15 pullRequestStatus["Draft"] = struct{}{}
16 pullRequestStatus["Approved"] = struct{}{}
17 pullRequestStatus["Changes requested"] = struct{}{}
18 pullRequestStatus["Review required"] = struct{}{}
19}
20
21func NewPullRequest(id int, name string, description string, status string, category string) *PullRequest {
22 pr := &PullRequest{
23 id: id,
24 name: name,
25 description: description,
26 status: status,
27 category: category,
28 }
29 return pr
30}
31
32func (pr PullRequest) Id() int {
33 return pr.id
34}
35
36func (pr PullRequest) Status() string {
37 return pr.status
38}
39
40func (pr *PullRequest) UpdateName(name string) {
41 pr.name = name
42}
43
44func (pr *PullRequest) UpdateDescription(description string) {
45 pr.description = description
46}
47
48func (pr *PullRequest) UpdateStatus(status string) bool {
49 if validateStatus(status) {
50 pr.status = status
51 return true
52 }
53 return false
54}
55
56func validateStatus(status string) bool {
57 _, ok := pullRequestStatus[status]
58 return ok
59}