@@ -18,7 +18,7 @@ const octo = new Octokat({token: config.ghToken});
18
18
const orgs = [ "w3c" , "WebAudio" , "immersive-web" , "webassembly" , "w3ctag" , "WICG" , "w3cping" ] ;
19
19
const errortypes = [ "inconsistentgroups" , "now3cjson" , "invalidw3cjson" , "illformedw3cjson" , "incompletew3cjson" , "nocontributing" , "invalidcontributing" , "nolicense" , "nocodeofconduct" , "invalidlicense" , "noreadme" , "noashnazg" , "inconsistentstatus" , "unprotectedbranch" , "missingashnazghook" , "duplicateashnazghooks" ] ;
20
20
21
- async function fetchLabelPage ( org , repo , acc = [ ] , cursor = null ) {
21
+ async function fetchLabelPage ( org , repo , acc = { edges : [ ] } , cursor = null ) {
22
22
console . warn ( "Fetching labels for " + repo ) ;
23
23
let res ;
24
24
try {
@@ -44,15 +44,15 @@ async function fetchLabelPage(org, repo, acc = [], cursor = null) {
44
44
console . error ( "query failed " + JSON . stringify ( err ) ) ;
45
45
}
46
46
if ( res && res . repository ) {
47
- const data = acc . concat ( res . repository . labels . edges ) ;
47
+ const labels = { edges : acc . edges . concat ( res . repository . labels . edges ) } ;
48
48
if ( res . repository . labels . pageInfo . hasNextPage ) {
49
- return fetchLabelPage ( org , repo , data , res . repository . labels . pageInfo . endCursor ) ;
49
+ return fetchLabelPage ( org , repo , labels , res . repository . labels . pageInfo . endCursor ) ;
50
50
} else {
51
- return { "repo" : { "owner" : org , "name" : repo } , " labels" : data . map ( e => e . node ) } ;
51
+ return { "repo" : { "owner" : org , "name" : repo } , labels} ;
52
52
}
53
53
} else {
54
54
console . error ( "Fetching label for " + repo + " at cursor " + cursor + " failed with " + JSON . stringify ( res ) + ", not retrying" ) ;
55
- return { "repo" : { "owner" : org , "name" : repo } , "labels" : acc . map ( e => e . node ) } ;
55
+ return { "repo" : { "owner" : org , "name" : repo } , "labels" : acc } ;
56
56
//return fetchLabelPage(org, repo, acc, cursor);
57
57
}
58
58
}
@@ -141,12 +141,18 @@ async function fetchRepoPage(org, acc = [], cursor = null) {
141
141
return Promise . all (
142
142
res . organization . repositories . edges
143
143
. filter ( e => e . node . labels . pageInfo . hasNextPage )
144
- . map ( e => fetchLabelPage ( e . node . owner . login , e . node . name , e . node . labels . edges , e . node . labels . pageInfo . endCursor ) )
144
+ . map ( e => fetchLabelPage ( e . node . owner . login , e . node . name , e . node . labels , e . node . labels . pageInfo . endCursor ) )
145
145
) . then ( ( labelsPerRepos ) => {
146
146
const data = acc . concat ( res . organization . repositories . edges . map ( e => e . node ) ) ;
147
147
labelsPerRepos . forEach ( ( { repo, labels} ) => {
148
148
data . find ( r => r . owner . login == repo . owner && r . name == repo . name ) . labels = labels ;
149
149
} ) ;
150
+ // Clean up labels data structure
151
+ data . forEach ( r => {
152
+ if ( r . labels && r . labels . edges ) {
153
+ r . labels = r . labels . edges . map ( e => e . node ) ;
154
+ }
155
+ } ) ;
150
156
if ( res . organization . repositories . pageInfo . hasNextPage ) {
151
157
return fetchRepoPage ( org , data , res . organization . repositories . pageInfo . endCursor ) ;
152
158
} else {
0 commit comments