1
1
package github
2
2
3
3
import (
4
- "golang.org/x/oauth2"
5
- "golang.org/x/net/context"
6
- "github.com/shurcooL/githubql"
7
- "github.com/google/go-github/github"
8
4
"net/http"
5
+
6
+ "github.com/google/go-github/github"
7
+ "github.com/shurcooL/githubql"
8
+ "golang.org/x/net/context"
9
+ "golang.org/x/oauth2"
9
10
)
10
11
11
12
type githubManager struct {
@@ -14,7 +15,7 @@ type githubManager struct {
14
15
HttpClient * http.Client
15
16
}
16
17
17
- func New (githubAccessToken string ) ( * githubManager ) {
18
+ func New (githubAccessToken string ) * githubManager {
18
19
ctx := context .Background ()
19
20
src := oauth2 .StaticTokenSource (
20
21
& oauth2.Token {AccessToken : githubAccessToken },
@@ -47,7 +48,7 @@ func (gm *githubManager) GetCommits(owner, repo, branch string, lastCommitsNumbe
47
48
return hydrateCommits (q ), nil
48
49
}
49
50
50
- func PickFirstParentCommits (fullCommitsList []Commit ) ( []Commit ) {
51
+ func PickFirstParentCommits (fullCommitsList []Commit ) []Commit {
51
52
var firstParentCommits []Commit
52
53
if 0 == len (fullCommitsList ) {
53
54
return firstParentCommits
@@ -76,7 +77,7 @@ func PickFirstParentCommits(fullCommitsList []Commit) ([]Commit) {
76
77
}
77
78
78
79
// TODO remove v3 client when implemented in v4
79
- func (gm * githubManager ) ChangeBranchHead (owner , repo , branch , sha string , force bool ) ( error ) {
80
+ func (gm * githubManager ) ChangeBranchHead (owner , repo , branch , sha string , force bool ) error {
80
81
httpClient := gm .HttpClient
81
82
82
83
client := github .NewClient (httpClient )
@@ -95,7 +96,7 @@ func (gm *githubManager) ChangeBranchHead(owner, repo, branch, sha string, force
95
96
return nil
96
97
}
97
98
98
- func hydrateCommits (q * githubQuery ) ( []Commit ) {
99
+ func hydrateCommits (q * githubQuery ) []Commit {
99
100
var fullCommitsList []Commit
100
101
for _ , edge := range q .Repository .Ref .Target .Commit .History .Edges {
101
102
var parents []Commit
@@ -105,11 +106,12 @@ func hydrateCommits(q *githubQuery) ([]Commit) {
105
106
Message : string (parent .Node .Message ),
106
107
})
107
108
}
109
+
108
110
fullCommitsList = append (fullCommitsList , Commit {
109
111
SHA : string (edge .Node .Oid ),
110
112
Message : string (edge .Node .Message ),
111
113
Parents : parents ,
112
- StatusSuccess : bool (edge .Node .Status .State == githubql .String (githubql .StatusStateSuccess )),
114
+ StatusSuccess : bool (edge .Node .StatusCheckRollup .State == githubql .String (githubql .StatusStateSuccess )),
113
115
PushedDate : edge .Node .PushedDate .Time ,
114
116
})
115
117
}
0 commit comments