Skip to content

Commit c4ef99e

Browse files
committed
Fix 502 bad gataway issue
1 parent 90e0866 commit c4ef99e

File tree

5 files changed

+630
-60
lines changed

5 files changed

+630
-60
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.idea/
22
vendor/
3+
4+
/.vscode/launch.json

github/github-query.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package github
22

3-
import "github.com/shurcooL/githubql"
3+
import "github.com/shurcooL/githubv4"
44

55
type githubQuery struct {
66
Repository struct {
@@ -13,36 +13,36 @@ type githubQuery struct {
1313
Parents struct {
1414
Edges []struct {
1515
Node struct {
16-
Oid githubql.String
17-
Message githubql.String
16+
Oid githubv4.String
17+
Message githubv4.String
1818
}
1919
}
2020
} `graphql:"parents(first: $parentsNumber)"`
21-
Oid githubql.String
22-
Message githubql.String
23-
PushedDate githubql.DateTime
21+
Oid githubv4.String
22+
Message githubv4.String
23+
PushedDate githubv4.DateTime
2424
StatusCheckRollup struct {
25-
State githubql.String
25+
State githubv4.String
2626
Contexts struct {
27-
TotalCount githubql.Int
27+
TotalCount githubv4.Int
2828
} `graphql:"contexts(first: $parentsNumber)"`
2929
}
3030
CheckSuites struct {
3131
Nodes []struct {
3232
CheckRuns struct {
3333
Nodes []struct {
34-
Name githubql.String
35-
Status githubql.String
36-
Title githubql.String
37-
Conclusion githubql.String
34+
Name githubv4.String
35+
Status githubv4.String
36+
Title githubv4.String
37+
Conclusion githubv4.String
3838
}
3939
} `graphql:"checkRuns(first: 100)"`
4040
}
4141
} `graphql:"checkSuites(first: 10)"`
4242
Status struct {
4343
Contexts []struct {
44-
Context githubql.String
45-
State githubql.String
44+
Context githubv4.String
45+
State githubv4.String
4646
}
4747
}
4848
}

github/manager.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import (
44
"net/http"
55

66
"github.com/google/go-github/github"
7-
"github.com/shurcooL/githubql"
7+
"github.com/shurcooL/githubv4"
88
"golang.org/x/net/context"
99
"golang.org/x/oauth2"
1010
)
1111

1212
type githubManager struct {
1313
Context context.Context
14-
Client *githubql.Client
14+
Client *githubv4.Client
1515
HttpClient *http.Client
1616
}
1717

@@ -21,7 +21,7 @@ func New(githubAccessToken string) *githubManager {
2121
&oauth2.Token{AccessToken: githubAccessToken},
2222
)
2323
httpClient := oauth2.NewClient(ctx, src)
24-
client := githubql.NewClient(httpClient)
24+
client := githubv4.NewClient(httpClient)
2525

2626
return &githubManager{Context: ctx, Client: client, HttpClient: httpClient}
2727
}
@@ -35,11 +35,11 @@ func (gm *githubManager) GetCommits(owner, repo, branch string, lastCommitsNumbe
3535

3636
client := gm.Client
3737
err := client.Query(gm.Context, &q, map[string]interface{}{
38-
"owner": githubql.String(owner),
39-
"name": githubql.String(repo),
40-
"branch": githubql.String(branch),
41-
"commitsNumber": githubql.Int(lastCommitsNumber),
42-
"parentsNumber": githubql.Int(1),
38+
"owner": githubv4.String(owner),
39+
"name": githubv4.String(repo),
40+
"branch": githubv4.String(branch),
41+
"commitsNumber": githubv4.Int(lastCommitsNumber),
42+
"parentsNumber": githubv4.Int(1),
4343
})
4444
if nil != err {
4545
return nil, err
@@ -112,21 +112,21 @@ func hydrateCommits(q *githubQuery, specificCheckName string) []Commit {
112112
if specificCheckName != "" {
113113
// first check if commit has commit status set
114114
for _, context := range edge.Node.Status.Contexts {
115-
if githubql.String(specificCheckName) == context.Context {
116-
statusSuccess = context.State == githubql.String(githubql.StatusStateSuccess)
115+
if githubv4.String(specificCheckName) == context.Context {
116+
statusSuccess = context.State == githubv4.String(githubv4.StatusStateSuccess)
117117
}
118118
}
119119

120120
// then check if commit has check-run set
121121
for _, checkSuite := range edge.Node.CheckSuites.Nodes {
122122
for _, checkRuns := range checkSuite.CheckRuns.Nodes {
123-
if githubql.String(specificCheckName) == checkRuns.Name {
124-
statusSuccess = checkRuns.Conclusion == githubql.String(githubql.StatusStateSuccess)
123+
if githubv4.String(specificCheckName) == checkRuns.Name {
124+
statusSuccess = checkRuns.Conclusion == githubv4.String(githubv4.StatusStateSuccess)
125125
}
126126
}
127127
}
128128
} else {
129-
statusSuccess = bool(edge.Node.StatusCheckRollup.State == githubql.String(githubql.StatusStateSuccess))
129+
statusSuccess = bool(edge.Node.StatusCheckRollup.State == githubv4.String(githubv4.StatusStateSuccess))
130130
}
131131

132132
fullCommitsList = append(fullCommitsList, Commit{

go.mod

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,40 @@ module github.com/Docplanner/github-flow-manager
33
go 1.16
44

55
require (
6-
github.com/araddon/dateparse v0.0.0-20180325234811-1d3842569f46 // indirect
7-
github.com/araddon/gou v0.0.0-20180315155215-820e9f87cd05 // indirect
8-
github.com/araddon/qlbridge v0.0.0-20180324211701-d31482986c59
9-
github.com/dchest/siphash v1.1.0 // indirect
10-
github.com/gogo/protobuf v1.0.0 // indirect
11-
github.com/golang/protobuf v1.0.0 // indirect
6+
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
7+
github.com/araddon/gou v0.0.0-20190110011759-c797efecbb61 // indirect
8+
github.com/araddon/qlbridge v0.0.2
9+
github.com/dchest/siphash v1.2.2 // indirect
10+
github.com/gogo/protobuf v1.3.2 // indirect
11+
github.com/golang/protobuf v1.5.2 // indirect
1212
github.com/google/btree v1.0.0 // indirect
13-
github.com/google/go-github v15.0.0+incompatible
14-
github.com/google/go-querystring v0.0.0-20170111101155-53e6ce116135 // indirect
13+
github.com/google/go-github v17.0.0+incompatible
14+
github.com/google/go-querystring v1.1.0 // indirect
15+
github.com/google/uuid v1.2.0 // indirect
1516
github.com/hashicorp/go-memdb v1.3.1 // indirect
1617
github.com/inconshreveable/mousetrap v1.0.0 // indirect
17-
github.com/jmespath/go-jmespath v0.0.0-20151117175822-3433f3ea46d9 // indirect
18+
github.com/jmespath/go-jmespath v0.4.0 // indirect
1819
github.com/jmoiron/sqlx v1.3.1 // indirect
1920
github.com/leekchan/timeutil v0.0.0-20150802142658-28917288c48d // indirect
20-
github.com/lytics/datemath v0.0.0-20161129202832-2c793e7cfff9 // indirect
21+
github.com/lytics/datemath v0.0.0-20180727225141-3ada1c10b5de // indirect
2122
github.com/lytics/logrus v0.0.0-20170528191427-4389a17ed024 // indirect
22-
github.com/mattn/go-runewidth v0.0.2 // indirect
23+
github.com/mattn/go-runewidth v0.0.13 // indirect
2324
github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4 // indirect
24-
github.com/mssola/user_agent v0.4.1 // indirect
25-
github.com/olekukonko/tablewriter v0.0.0-20180130162743-b8a9be070da4
26-
github.com/pborman/uuid v0.0.0-20170612153648-e790cca94e6c // indirect
27-
github.com/shurcooL/githubql v0.0.0-20180322230020-d8297a7d5a84
28-
github.com/shurcooL/go v0.0.0-20180221041408-364c5ae8518b // indirect
29-
github.com/shurcooL/graphql v0.0.0-20180302221403-3d276b9dcc6b // indirect
25+
github.com/mssola/user_agent v0.5.3 // indirect
26+
github.com/olekukonko/tablewriter v0.0.5
27+
github.com/pborman/uuid v1.2.1 // indirect
28+
github.com/rivo/uniseg v0.2.0 // indirect
29+
github.com/shurcooL/githubv4 v0.0.0-20201206200315-234843c633fa
30+
github.com/shurcooL/graphql v0.0.0-20200928012149-18c5c3165e3a // indirect
3031
github.com/simplereach/timeutils v1.2.0 // indirect
31-
github.com/spf13/cobra v0.0.2
32-
github.com/spf13/pflag v1.0.0 // indirect
32+
github.com/spf13/cobra v1.1.3
33+
github.com/spf13/pflag v1.0.5 // indirect
3334
github.com/stretchr/testify v1.7.0 // indirect
34-
golang.org/x/net v0.0.0-20180320002117-6078986fec03
35-
golang.org/x/oauth2 v0.0.0-20180314180239-fdc9e635145a
35+
golang.org/x/net v0.0.0-20210525063256-abc453219eb5
36+
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
3637
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
37-
golang.org/x/sys v0.0.0-20180404071108-f67933eaf9e2 // indirect
38-
google.golang.org/appengine v1.0.0 // indirect
38+
golang.org/x/sys v0.0.0-20210603125802-9665404d3644 // indirect
39+
google.golang.org/appengine v1.6.7 // indirect
40+
google.golang.org/protobuf v1.26.0 // indirect
3941
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
4042
)

0 commit comments

Comments
 (0)