-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmodels.go
84 lines (74 loc) · 1.98 KB
/
models.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
package resource
import "github.com/shurcooL/githubv4"
// Metadata output from get/put steps.
type Metadata []*MetadataField
// Add a MetadataField to the Metadata.
func (m *Metadata) Add(name, value string) {
*m = append(*m, &MetadataField{Name: name, Value: value})
}
// MetadataField ...
type MetadataField struct {
Name string `json:"name"`
Value string `json:"value"`
}
// PullRequest represents a pull request and includes the tip (commit).
type PullRequest struct {
PullRequestObject
Tip CommitObject
ApprovedReviewCount int
Labels []LabelObject
}
// PullRequestObject represents the GraphQL commit node.
// https://developer.github.com/v4/object/pullrequest/
type PullRequestObject struct {
ID string
Number int
Title string
URL string
BaseRefName string
HeadRefName string
Repository struct {
URL string
}
IsCrossRepository bool
IsDraft bool
State githubv4.PullRequestState
ClosedAt githubv4.DateTime
MergedAt githubv4.DateTime
}
// UpdatedDate returns the last time a PR was updated, either by commit
// or being closed/merged.
func (p *PullRequest) UpdatedDate() githubv4.DateTime {
date := p.Tip.CommittedDate
switch p.State {
case githubv4.PullRequestStateClosed:
date = p.ClosedAt
case githubv4.PullRequestStateMerged:
date = p.MergedAt
}
return date
}
// CommitObject represents the GraphQL commit node.
// https://developer.github.com/v4/object/commit/
type CommitObject struct {
ID string
OID string
CommittedDate githubv4.DateTime
Message string
Author struct {
User struct {
Login string
}
Email string
}
}
// ChangedFileObject represents the GraphQL FilesChanged node.
// https://developer.github.com/v4/object/pullrequestchangedfile/
type ChangedFileObject struct {
Path string
}
// LabelObject represents the GraphQL label node.
// https://developer.github.com/v4/object/label
type LabelObject struct {
Name string
}