Skip to content

Commit bb82694

Browse files
Merge pull request #59 from w3c/cgRepo-lookup
Fix a misnested `.find(...)` expression for CG lookup
2 parents 0da4369 + 5fab479 commit bb82694

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

lib/validator.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ function validateRepo(r, licenses, repoData, cgData, repoMap) {
7070
let shouldBeRepoManaged = false;
7171
const hasRecTrack = {ashnazg: null, repotype: null, tr: null}; // TODO detect conflicting information (repo-type vs ash-nazg vs TR doc)
7272

73-
let groups = [];
7473
// is the repo associated with a CG in the CG monitor?
75-
const cgRepo = cgData.data.find(cg => cg.repositories.includes('https://github.com/' + fullName(r) || cg.repositories.includes('https://github.com/' + fullName(r) + '/'))) ||
76-
// is the repo in WICG space?
77-
(r.owner.login === 'WICG' ? {id: 80485} : null);
74+
const cg = cgData.data.find(cg => {
75+
return cg.repositories.includes('https://github.com/' + fullName(r)) ||
76+
cg.repositories.includes('https://github.com/' + fullName(r) + '/');
77+
});
78+
7879
// is the repo associated with a WG in the spec dashboard?
7980
const wgRepo = repoMap[fullName(r)];
80-
const audioWgRepo = r.owner.login === 'WebAudio' ? {id: 46884} : null;
81+
8182
if (wgRepo) {
8283
hasRecTrack.tr = wgRepo.some(x => x.recTrack);
8384
}
@@ -104,6 +105,8 @@ function validateRepo(r, licenses, repoData, cgData, repoMap) {
104105
} else if (hardcodedRepoData[fullName(r)]) {
105106
conf = hardcodedRepoData[fullName(r)];
106107
}
108+
109+
let groups = [];
107110
if (conf) {
108111
r.w3c = conf;
109112
// TODO: replace with JSON schema?
@@ -131,14 +134,16 @@ function validateRepo(r, licenses, repoData, cgData, repoMap) {
131134
}
132135
}
133136
} else {
134-
if (cgRepo) {
135-
groups = [cgRepo.id];
137+
if (cg) {
138+
groups = [cg.id];
139+
} else if (r.owner.login === 'WICG') {
140+
groups = [80485];
136141
}
137142
if (wgRepo && wgRepo.length) {
138143
groups = groups.concat(wgRepo.map(x => x.group));
139144
}
140-
if (audioWgRepo) {
141-
groups.push(audioWgRepo.id);
145+
if (r.owner.login === 'WebAudio') {
146+
groups.push(46884);
142147
}
143148
reportError('now3cjson');
144149
}

test/validator.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,10 @@ describe('validateRepo', () => {
204204
const repoData = [];
205205
const cgData = {data: [{
206206
id: 45,
207-
repositories: ['https://github.com/foo/bar'],
207+
repositories: ['https://github.com/foo/bar/'],
208208
}]};
209209
const repoMap = {};
210210
const {groups} = validateRepo(repo, licenses, repoData, cgData, repoMap);
211-
// Note: id from `cgData` clobbers id from `repoData`
212211
assert.deepStrictEqual(groups, [45]);
213212
});
214213

@@ -222,7 +221,6 @@ describe('validateRepo', () => {
222221
const cgData = {data: []};
223222
const repoMap = {};
224223
const {groups} = validateRepo(repo, licenses, repoData, cgData, repoMap);
225-
// Note: hardcoded WICG group id clobbers id from `repoData`
226224
assert.deepStrictEqual(groups, [80485]);
227225
});
228226

0 commit comments

Comments
 (0)