forked from Songmu/ghch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
octokit.go
57 lines (52 loc) · 1.26 KB
/
octokit.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
package ghch
import (
"github.com/google/go-github/github"
)
func reducePR(pr *github.PullRequest) *github.PullRequest {
return &github.PullRequest{
HTMLURL: pr.HTMLURL,
Title: pr.Title,
Number: pr.Number,
State: pr.State,
Body: pr.Body,
CreatedAt: pr.CreatedAt,
UpdatedAt: pr.UpdatedAt,
MergedAt: pr.MergedAt,
MergeCommitSHA: pr.MergeCommitSHA,
User: reduceUser(pr.User),
Head: reducePullRequestBranch(pr.Head),
Base: reducePullRequestBranch(pr.Base),
MergedBy: reduceUser(pr.MergedBy),
}
}
func reduceUser(u *github.User) *github.User {
if u == nil {
return u
}
return &github.User{
Login: u.Login,
AvatarURL: u.AvatarURL,
Type: u.Type,
HTMLURL: u.HTMLURL,
}
}
func reduceRepo(r *github.Repository) *github.Repository {
if r == nil {
return nil
}
return &github.Repository{
Owner: reduceUser(r.Owner),
Name: r.Name,
FullName: r.FullName,
HTMLURL: r.HTMLURL,
}
}
func reducePullRequestBranch(prb *github.PullRequestBranch) *github.PullRequestBranch {
return &github.PullRequestBranch{
Label: prb.Label,
Ref: prb.Ref,
SHA: prb.SHA,
User: reduceUser(prb.User),
Repo: reduceRepo(prb.Repo),
}
}