-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
99 lines (82 loc) · 2.26 KB
/
types.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package castor
import (
"fmt"
"time"
)
// ExitError implements the cli.ExitError interface
type ExitError struct {
error
code int
}
// ExitCode returns the error code
func (e ExitError) ExitCode() int {
return e.code
}
// ExitErr returns an ExitError based on an error code an another error value.
func ExitErr(code int, err error) ExitError {
switch v := err.(type) {
// TODO: should we ignore `code` in this case?
case ExitError:
return v
default:
return ExitError{err, code}
}
}
// ExitErrorF returns an ExitError based on an error code and a format specifier.
func ExitErrorF(code int, format string, a ...interface{}) ExitError {
return ExitError{fmt.Errorf(format, a...), code}
}
type Label struct {
Name string `json:"name"`
Color string `json:"color"`
}
type Ref struct {
Ref string `json:"ref"`
}
type WithLogin struct {
Login string `json:"login"`
}
type PRsSearch struct {
IssueCount int `json:"issueCount"`
Nodes []SearchPR `json:"nodes"`
}
type SearchPR struct {
URL string `json:"url"`
Number int `json:"number"`
Title string `json:"title"`
Author WithLogin `json:"author"`
HeadRefName string `json:"headRefName"`
HeadRepository Name `json:"headRepository"`
HeadRepositoryOwner Login `json:"headRepositoryOwner"`
Closed bool `json:"closed"`
Merged bool `json:"Merged"`
Labels Labels `json:"Labels"`
ReviewRequests ReviewRequests `json:"reviewRequests"`
}
type Name struct {
Name string `json:"name"`
}
type Login struct {
Login string `json:"login"`
}
type LoginAndName struct {
Login string `json:"login"`
Name string `json:"name"`
}
type Review struct {
State string `json:"state"`
SubmittedAt time.Time `json:"submittedAt"`
URL string `json:"url"`
Author WithLogin `json:"Author"`
}
type RequestedReviewer struct {
RequestedReviewer LoginAndName `json:"requestedReviewer"`
}
type ReviewRequests struct {
TotalCount int `json:"totalCount"`
Nodes []RequestedReviewer `json:"Nodes"`
}
type Labels struct {
TotalCount int `json:"totalCount"`
Nodes []Label `json:"nodes"`
}