-
Notifications
You must be signed in to change notification settings - Fork 0
/
review.go
74 lines (62 loc) · 1.71 KB
/
review.go
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package fastlane
import "encoding/json"
type Review struct {
ID string `json:"id"`
ProjectID string `json:"project_id"`
Title string `json:"title"`
Description string `json:"description"`
Author User `json:"author"`
WebURL string `json:"web_url"`
Approvals []User `json:"approvals"`
CanBeMerged bool `json:"can_be_merged"`
Merged bool `json:"merged"`
SHA string `json:"sha"`
MergeCommitSHA string `json:"merge_commit_sha"`
}
func (r Review) IsApproved() bool {
return len(r.Approvals) > 0
}
func (r Review) MergeEnabled() bool {
return r.IsApproved() && r.CanBeMerged
}
type enhancedReview Review
func (r Review) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
enhancedReview
MergeEnabled bool `json:"merge_enabled"`
}{
enhancedReview: enhancedReview(r),
MergeEnabled: r.MergeEnabled(),
})
}
type Pipeline struct {
ID string `json:"id"`
Project string `json:"project"`
ReviewID string `json:"review_id"`
Running bool `json:"running"`
Success bool `json:"success"`
Status Status `json:"status"`
WebURL string `json:"web_url"`
Stages []Stage `json:"stages"`
Coverage float64 `json:"coverage"`
}
type Stage struct {
Name string `json:"name"`
Status Status `json:"status"`
Jobs []Job `json:"jobs"`
}
type Job struct {
Name string `json:"name"`
Status Status `json:"status"`
WebURL string `json:"web_url"`
}
type Status string
const (
SuccessStatus Status = "success"
FailedStatus Status = "failed"
SkippedStatus Status = "skipped"
RunningStatus Status = "running"
PendingStatus Status = "pending"
CanceledStatus Status = "canceled"
ManualStatus Status = "manual"
)