-
Notifications
You must be signed in to change notification settings - Fork 4
/
github.go
125 lines (106 loc) · 2.84 KB
/
github.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package github
import "time"
// DEVELOPMENT OF THIS HAS NOW MOVED TO https://github.com/betandr/prt
// THIS WON'T BE UPDATED ANYMORE SO WILL CONTAIN BUGS ETC
// PullRequestsURL is the Github API URL
const PullRequestsURL = "https://api.github.com"
// PullRequestsResult represents a collection of PullRequests
type PullRequestsResult struct {
PullRequests []*PullRequest
}
// User represents a GitHub user
type User struct {
Login string
}
// Head is the branch the PR is on
type Head struct {
Ref string
}
// Base is the branch this PR's branch is from
type Base struct {
Ref string
}
// Users is collection of `User`s
type Users []User
// CommitDetails are extra details for the commit
type CommitDetails struct {
Message string
}
// Commit from a PR
type Commit struct {
SHA string
Author User
CommitDetails `json:"commit"`
UpdatedAt string `json:"updated_at"`
}
// Commits is a collection of `Commit`s (obvs)
type Commits []Commit
// Comment from a PR
type Comment struct {
ID int
User User
UpdatedAt time.Time `json:"updated_at"`
Body string
}
// Status from a PR
type Status struct {
ID int
State string
Description string
TargetURL string `json:"target_url"`
UpdatedAt time.Time `json:"updated_at"`
}
// NewPullRequest is used when opening a new pull request
type NewPullRequest struct {
Title string `json:"title"`
Body string `json:"body"`
Head string `json:"head"`
Base string `json:"base"`
}
// PatchPullRequest is used to update a PR
type PatchPullRequest struct {
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
Base string `json:"base"`
}
// Error shows feedback from the API
type Error struct {
Message string
Errors []*ErrorMessage
}
// ErrorMessage is used in an `Error`
type ErrorMessage struct {
Message string
}
// MergeStatus shows the status of a merge request
type MergeStatus struct {
SHA string `json:"sha"`
Merged bool `json:"merged"`
Message string `json:"message"`
}
// PullRequest represents a single pull request
type PullRequest struct {
Number int
State string
Locked bool
Title string
Body string
StatusesURL string `json:"statuses_url"`
HTMLUrl string `json:"html_url"`
User User
CreatedAt time.Time `json:"created_at"`
MergedAt time.Time `json:"merged_at"`
MergeCommitSha string `json:"merge_commit_sha"`
Head Head
Base Base
RequestedReviewers Users `json:"requested_reviewers"`
Mergeable bool
Rebaseable bool
MergeableState string `json:"mergeable_state"`
MergedBy User `json:"merged_by"`
Commits int
Additions int
Deletions int
ChangedFiles int `json:"changed_files"`
}