Skip to content

Commit 8deb564

Browse files
authored
Merge branch 'main' into case-sensitivity
2 parents 0ac1a88 + d39f418 commit 8deb564

File tree

12 files changed

+78
-62
lines changed

12 files changed

+78
-62
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
entitlements-github-plugin (0.4.3)
4+
entitlements-github-plugin (0.4.4)
55
contracts (~> 0.17.0)
66
faraday (~> 2.0)
77
faraday-retry (~> 2.0)

lib/entitlements/service/github.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ def members_and_roles_from_graphql
210210
login
211211
}
212212
role
213-
cursor
214213
}
214+
pageInfo { endCursor }
215215
}
216216
}
217217
}".gsub(/\n\s+/, "\n")
@@ -222,14 +222,15 @@ def members_and_roles_from_graphql
222222
raise "GraphQL query failure"
223223
end
224224

225-
edges = response[:data].fetch("data").fetch("organization").fetch("membersWithRole").fetch("edges")
225+
membersWithRole = response[:data].fetch("data").fetch("organization").fetch("membersWithRole")
226+
edges = membersWithRole.fetch("edges")
226227
break unless edges.any?
227228

228229
edges.each do |edge|
229230
result[edge.fetch("node").fetch("login").downcase] = edge.fetch("role")
230231
end
231232

232-
cursor = edges.last.fetch("cursor")
233+
cursor = membersWithRole.fetch("pageInfo").fetch("endCursor")
233234
next if cursor && edges.size == max_graphql_results
234235
break
235236
end
@@ -276,8 +277,8 @@ def pending_members_from_graphql
276277
node {
277278
login
278279
}
279-
cursor
280280
}
281+
pageInfo { endCursor }
281282
}
282283
}
283284
}".gsub(/\n\s+/, "\n")
@@ -288,14 +289,15 @@ def pending_members_from_graphql
288289
raise "GraphQL query failure"
289290
end
290291

291-
edges = response[:data].fetch("data").fetch("organization").fetch("pendingMembers").fetch("edges")
292+
pendingMembers = response[:data].fetch("data").fetch("organization").fetch("pendingMembers")
293+
edges = pendingMembers.fetch("edges")
292294
break unless edges.any?
293295

294296
edges.each do |edge|
295297
result.add(edge.fetch("node").fetch("login").downcase)
296298
end
297299

298-
cursor = edges.last.fetch("cursor")
300+
cursor = pendingMembers.fetch("pageInfo").fetch("endCursor")
299301
next if cursor && edges.size == max_graphql_results
300302
break
301303
end

lib/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Entitlements
44
module Version
5-
VERSION = "0.4.3"
5+
VERSION = "0.4.4"
66
end
77
end

spec/acceptance/github-server/web.rb

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,22 @@ def graphql_org_query(query)
113113

114114
edges = []
115115
cursor_flag = cursor.nil?
116+
end_cursor = nil
116117
result.each do |user, role|
117-
next if !cursor_flag && Base64.strict_encode64(user) != cursor
118-
edges << { "node" => { "login" => user }, "role" => role, "cursor" => Base64.strict_encode64(user) } if cursor_flag
118+
end_cursor = Base64.strict_encode64(user)
119+
next if !cursor_flag && end_cursor != cursor
120+
edges << { "node" => { "login" => user }, "role" => role} if cursor_flag
119121
cursor_flag = true
120122
break if edges.size >= first
121123
end
122124

123125
{
124126
"organization" => {
125127
"membersWithRole" => {
126-
"edges" => edges
128+
"edges" => edges,
129+
"pageInfo" => {
130+
"endCursor" => end_cursor
131+
}
127132
}
128133
}
129134
}
@@ -144,17 +149,22 @@ def graphql_pending_query(query)
144149

145150
edges = []
146151
cursor_flag = cursor.nil?
152+
end_cursor = nil
147153
result.each do |user|
148-
next if !cursor_flag && Base64.strict_encode64(user) != cursor
149-
edges << { "node" => { "login" => user }, "cursor" => Base64.strict_encode64(user) } if cursor_flag
154+
end_cursor = Base64.strict_encode64(user)
155+
next if !cursor_flag && end_cursor != cursor
156+
edges << { "node" => { "login" => user } } if cursor_flag
150157
cursor_flag = true
151158
break if edges.size >= first
152159
end
153160

154161
{
155162
"organization" => {
156163
"pendingMembers" => {
157-
"edges" => edges
164+
"edges" => edges,
165+
"pageInfo" => {
166+
"endCursor" => end_cursor
167+
}
158168
}
159169
}
160170
}

spec/unit/fixtures/graphql-output/organization-members-page1.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
"node": {
88
"login": "monalisa"
99
},
10-
"role": "ADMIN",
11-
"cursor": "Y3Vyc29yOnYyOpEB"
10+
"role": "ADMIN"
1211
},
1312
{
1413
"node": {
1514
"login": "ocicat"
1615
},
17-
"role": "MEMBER",
18-
"cursor": "Y3Vyc29yOnYyOpEF"
16+
"role": "MEMBER"
1917
},
2018
{
2119
"node": {
2220
"login": "blackmanx"
2321
},
24-
"role": "MEMBER",
25-
"cursor": "Y3Vyc29yOnYyOpEG"
22+
"role": "MEMBER"
2623
}
27-
]
24+
],
25+
"pageInfo": {
26+
"endCursor": "Y3Vyc29yOnYyOpEG"
27+
}
2828
}
2929
}
3030
}

spec/unit/fixtures/graphql-output/organization-members-page2.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
"node": {
88
"login": "toyger"
99
},
10-
"role": "MEMBER",
11-
"cursor": "Y3Vyc29yOnYyOpEH"
10+
"role": "MEMBER"
1211
},
1312
{
1413
"node": {
1514
"login": "highlander"
1615
},
17-
"role": "MEMBER",
18-
"cursor": "Y3Vyc29yOnYyOpEI"
16+
"role": "MEMBER"
1917
},
2018
{
2119
"node": {
2220
"login": "RussianBlue"
2321
},
24-
"role": "MEMBER",
25-
"cursor": "Y3Vyc29yOnYyOpEJ"
22+
"role": "MEMBER"
2623
}
27-
]
24+
],
25+
"pageInfo": {
26+
"endCursor": "Y3Vyc29yOnYyOpEJ"
27+
}
2828
}
2929
}
3030
}

spec/unit/fixtures/graphql-output/organization-members-page3.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
"node": {
88
"login": "ragamuffin"
99
},
10-
"role": "MEMBER",
11-
"cursor": "Y3Vyc29yOnYyOpEK"
10+
"role": "MEMBER"
1211
},
1312
{
1413
"node": {
1514
"login": "mainecoon"
1615
},
17-
"role": "MEMBER",
18-
"cursor": "Y3Vyc29yOnYyOpEL"
16+
"role": "MEMBER"
1917
},
2018
{
2119
"node": {
2220
"login": "laperm"
2321
},
24-
"role": "MEMBER",
25-
"cursor": "Y3Vyc29yOnYyOpEM"
22+
"role": "MEMBER"
2623
}
27-
]
24+
],
25+
"pageInfo": {
26+
"endCursor": "Y3Vyc29yOnYyOpEM"
27+
}
2828
}
2929
}
3030
}

spec/unit/fixtures/graphql-output/organization-members-page4.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
"node": {
88
"login": "peterbald"
99
},
10-
"role": "MEMBER",
11-
"cursor": "Y3Vyc29yOnYyOpEN"
10+
"role": "MEMBER"
1211
}
13-
]
12+
],
13+
"pageInfo": {
14+
"endCursor": "Y3Vyc29yOnYyOpEN"
15+
}
1416
}
1517
}
1618
}

spec/unit/fixtures/graphql-output/pending-members-page1.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
{
77
"node": {
88
"login": "alice"
9-
},
10-
"cursor": "Y3Vyc29yOnYyOpEB"
9+
}
1110
},
1211
{
1312
"node": {
1413
"login": "bob"
15-
},
16-
"cursor": "Y3Vyc29yOnYyOpEF"
14+
}
1715
},
1816
{
1917
"node": {
2018
"login": "charles"
21-
},
22-
"cursor": "Y3Vyc29yOnYyOpEG"
2319
}
24-
]
20+
}
21+
],
22+
"pageInfo": {
23+
"endCursor": "Y3Vyc29yOnYyOpEG"
24+
}
2525
}
2626
}
2727
}

spec/unit/fixtures/graphql-output/pending-members-page2.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
{
77
"node": {
88
"login": "DAVID"
9-
},
10-
"cursor": "Y3Vyc29yOnYyOpEH"
9+
}
1110
},
1211
{
1312
"node": {
1413
"login": "edward"
15-
},
16-
"cursor": "Y3Vyc29yOnYyOpEI"
14+
}
1715
},
1816
{
1917
"node": {
2018
"login": "frank"
21-
},
22-
"cursor": "Y3Vyc29yOnYyOpEJ"
19+
}
2320
}
24-
]
21+
],
22+
"pageInfo": {
23+
"endCursor": "Y3Vyc29yOnYyOpEJ"
24+
}
2525
}
2626
}
2727
}

0 commit comments

Comments
 (0)