Skip to content

Commit 7382454

Browse files
authored
fix(git-node): update README parser to account the recent TSC changes (#688)
BREAKING CHANGE: Old README format is no longer supported
1 parent f334713 commit 7382454

File tree

9 files changed

+126
-21
lines changed

9 files changed

+126
-21
lines changed

lib/collaborators.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import fs from 'node:fs';
22

3-
const TSC_TITLE = '### TSC (Technical Steering Committee)';
4-
const TSCE_TITLE = '### TSC Emeriti';
3+
const TSC_TITLE = '#### TSC voting members';
4+
const TSC_REGULAR_TITLE = '#### TSC regular members';
5+
const TSCE_TITLE = '#### TSC emeriti members';
56
const CL_TITLE = '### Collaborators';
6-
const CLE_TITLE = '### Collaborator Emeriti';
7+
const CLE_TITLE = '### Collaborator emeriti';
78
const CONTACT_RE = /\* +\[(.+?)\]\(.+?\) +-\s+\*\*([^*]+?)\*\* +(?:&lt;|\\<|<<)([^>]+?)(?:&gt;|>)/mg;
89

910
const TSC = 'TSC';
@@ -73,13 +74,17 @@ function parseCollaborators(readme, cli) {
7374
let m;
7475

7576
const tscIndex = readme.toUpperCase().indexOf(TSC_TITLE.toUpperCase());
77+
const tscrIndex = readme.toUpperCase().indexOf(TSC_REGULAR_TITLE.toUpperCase());
7678
const tsceIndex = readme.toUpperCase().indexOf(TSCE_TITLE.toUpperCase());
7779
const clIndex = readme.toUpperCase().indexOf(CL_TITLE.toUpperCase());
7880
const cleIndex = readme.toUpperCase().indexOf(CLE_TITLE.toUpperCase());
7981

8082
if (tscIndex === -1) {
8183
throw new Error(`Couldn't find ${TSC_TITLE} in the README`);
8284
}
85+
if (tscrIndex === -1) {
86+
throw new Error(`Couldn't find ${TSC_REGULAR_TITLE} in the README`);
87+
}
8388
if (tsceIndex === -1) {
8489
throw new Error(`Couldn't find ${TSCE_TITLE} in the README`);
8590
}
@@ -90,7 +95,8 @@ function parseCollaborators(readme, cli) {
9095
throw new Error(`Couldn't find ${CLE_TITLE} in the README`);
9196
}
9297

93-
if (!(tscIndex < tsceIndex &&
98+
if (!(tscIndex < tscrIndex &&
99+
tscrIndex < tsceIndex &&
94100
tsceIndex < clIndex &&
95101
clIndex < cleIndex)) {
96102
cli.warn('Contacts in the README is out of order, ' +
@@ -100,7 +106,7 @@ function parseCollaborators(readme, cli) {
100106
// We also assume that TSC & TSC Emeriti are also listed as collaborators
101107
CONTACT_RE.lastIndex = tscIndex;
102108
// eslint-disable-next-line no-cond-assign
103-
while ((m = CONTACT_RE.exec(readme)) && CONTACT_RE.lastIndex < tsceIndex) {
109+
while ((m = CONTACT_RE.exec(readme)) && CONTACT_RE.lastIndex < tscrIndex) {
104110
const login = m[1].toLowerCase();
105111
const user = new Collaborator(m[1], m[2], m[3], TSC);
106112
collaborators.set(login, user);

test/fixtures/README/README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,26 @@ For more information about the governance of the Node.js project, see
234234

235235
### TSC (Technical Steering Committee)
236236

237+
#### TSC voting members
238+
237239
* [bar](https://github.com/bar) -
238240
**Bar User** <<[email protected]>> (she/her)
239241

240-
### TSC emeriti
242+
#### TSC regular members
243+
244+
* [Baz](https://github.com/Baz) -
245+
**Baz User** &lt;[email protected]&gt; (he/him)
246+
247+
<details>
248+
249+
<summary>TSC emeriti members</summary>
250+
251+
#### TSC emeriti members
241252

242253
* [test](https://github.com/test) -
243-
**Test** &lt;[email protected]&gt;
254+
**Test User** <<[email protected]>>
255+
256+
</details>
244257

245258
### Collaborators
246259

@@ -257,11 +270,17 @@ For more information about the governance of the Node.js project, see
257270
* [ExtraSpace](https://github.com/extraspace) -
258271
**Extra Space** &lt;[email protected]&gt; (he/him)
259272

273+
<details>
274+
275+
<summary>Emeriti</summary>
276+
260277
### Collaborator emeriti
261278

262279
* [bee](https://github.com/bee) -
263280
**bee** &lt;[email protected]&gt;
264281

282+
</details>
283+
265284
Collaborators follow the [COLLABORATOR_GUIDE.md](./COLLABORATOR_GUIDE.md) in
266285
maintaining the Node.js project.
267286

test/fixtures/README/README_alternative.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,20 @@ For more information about the governance of the Node.js project, see
234234

235235
### TSC (Technical Steering Committee)
236236

237+
#### TSC voting members
238+
237239
* [bar](https://github.com/bar) -
238240
**Bar User (张三)** &lt;[email protected]&gt; (she/her)
239241

240-
### TSC Emeriti
242+
#### TSC regular members
243+
244+
<details>
245+
246+
<summary>TSC emeriti members</summary>
247+
248+
#### TSC emeriti members
249+
250+
</details>
241251

242252
### Collaborators
243253

@@ -246,7 +256,13 @@ For more information about the governance of the Node.js project, see
246256
* [Baz](https://github.com/Baz) -
247257
**Baz User** &lt;[email protected]&gt; (he/him)
248258

249-
### Collaborator Emeriti
259+
<details>
260+
261+
<summary>Emeriti</summary>
262+
263+
### Collaborator emeriti
264+
265+
</details>
250266

251267
Collaborators follow the [COLLABORATOR_GUIDE.md](./COLLABORATOR_GUIDE.md) in
252268
maintaining the Node.js project.

test/fixtures/README/README_no_TSC.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,19 @@ that forms the _Technical Steering Committee_ (TSC) which governs the project.
231231
For more information about the governance of the Node.js project, see
232232
[GOVERNANCE.md](./GOVERNANCE.md).
233233

234-
### TSC Emeriti
234+
### TSC (Technical Steering Committee)
235+
236+
<details>
237+
238+
<summary>TSC emeriti members</summary>
239+
240+
#### TSC emeriti members
235241

236242
* [test](https://github.com/test) -
237243
**Test** &lt;[email protected]&gt;
238244

245+
</details>
246+
239247
### Collaborators
240248

241249
* [bar](https://github.com/bar) -
@@ -247,11 +255,17 @@ For more information about the governance of the Node.js project, see
247255
* [Quo](https://github.com/quo) -
248256
**Quo User** &lt;[email protected]&gt; (she/her)
249257

250-
### Collaborator Emeriti
258+
<details>
259+
260+
<summary>Emeriti</summary>
261+
262+
### Collaborator emeriti
251263

252264
* [bee](https://github.com/bee) -
253265
**bee** &lt;[email protected]&gt;
254266

267+
</details>
268+
255269
Collaborators follow the [COLLABORATOR_GUIDE.md](./COLLABORATOR_GUIDE.md) in
256270
maintaining the Node.js project.
257271

test/fixtures/README/README_no_TSCE.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ For more information about the governance of the Node.js project, see
234234

235235
### TSC (Technical Steering Committee)
236236

237+
#### TSC voting members
238+
237239
* [bar](https://github.com/bar) -
238240
**Bar User** &lt;[email protected]&gt; (she/her)
239241

@@ -248,11 +250,17 @@ For more information about the governance of the Node.js project, see
248250
* [Quo](https://github.com/quo) -
249251
**Quo User** &lt;[email protected]&gt; (she/her)
250252

251-
### Collaborator Emeriti
253+
<details>
254+
255+
<summary>Emeriti</summary>
256+
257+
### Collaborator emeriti
252258

253259
* [bee](https://github.com/bee) -
254260
**bee** &lt;[email protected]&gt;
255261

262+
</details>
263+
256264
Collaborators follow the [COLLABORATOR_GUIDE.md](./COLLABORATOR_GUIDE.md) in
257265
maintaining the Node.js project.
258266

test/fixtures/README/README_no_collaboratorE.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,24 @@ For more information about the governance of the Node.js project, see
234234

235235
### TSC (Technical Steering Committee)
236236

237+
#### TSC voting members
238+
237239
* [bar](https://github.com/bar) -
238240
**Bar User** &lt;[email protected]&gt; (she/her)
239241

240-
### TSC Emeriti
242+
#### TSC regular members
243+
244+
<details>
245+
246+
<summary>TSC emeriti members</summary>
247+
248+
#### TSC emeriti members
241249

242250
* [test](https://github.com/test) -
243251
**Test** &lt;[email protected]&gt;
244252

253+
</details>
254+
245255
### Collaborators
246256

247257
* [bar](https://github.com/bar) -

test/fixtures/README/README_no_collaborators.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,19 +233,35 @@ For more information about the governance of the Node.js project, see
233233

234234
### TSC (Technical Steering Committee)
235235

236+
#### TSC voting members
237+
236238
* [bar](https://github.com/bar) -
237239
**Bar User** &lt;[email protected]&gt; (she/her)
238240

239-
### TSC Emeriti
241+
#### TSC regular members
242+
243+
<details>
244+
245+
<summary>TSC emeriti members</summary>
246+
247+
#### TSC emeriti members
240248

241249
* [test](https://github.com/test) -
242250
**Test** &lt;[email protected]&gt;
243251

244-
### Collaborator Emeriti
252+
</details>
253+
254+
<details>
255+
256+
<summary>Emeriti</summary>
257+
258+
### Collaborator emeriti
245259

246260
* [bee](https://github.com/bee) -
247261
**bee** &lt;[email protected]&gt;
248262

263+
</details>
264+
249265
Collaborators follow the [COLLABORATOR_GUIDE.md](./COLLABORATOR_GUIDE.md) in
250266
maintaining the Node.js project.
251267

test/fixtures/README/README_unordered.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,17 @@ that forms the _Technical Steering Committee_ (TSC) which governs the project.
232232
For more information about the governance of the Node.js project, see
233233
[GOVERNANCE.md](./GOVERNANCE.md).
234234

235-
### Collaborator Emeriti
235+
<details>
236+
237+
<summary>Emeriti</summary>
238+
239+
### Collaborator emeriti
236240

237241
* [bee](https://github.com/bee) -
238242
**bee** &lt;[email protected]&gt;
239243

244+
</details>
245+
240246
Collaborators follow the [COLLABORATOR_GUIDE.md](./COLLABORATOR_GUIDE.md) in
241247
maintaining the Node.js project.
242248

@@ -251,12 +257,22 @@ maintaining the Node.js project.
251257
* [Quo](https://github.com/quo) -
252258
**Quo User** &lt;[email protected]&gt; (she/her)
253259

254-
### TSC Emeriti
260+
### TSC (Technical Steering Committee)
261+
262+
<details>
263+
264+
<summary>Emeriti</summary>
265+
266+
#### TSC emeriti members
255267

256268
* [test](https://github.com/test) -
257269
**Test** &lt;[email protected]&gt;
258270

259-
### TSC (Technical Steering Committee)
271+
</details>
272+
273+
#### TSC regular members
274+
275+
#### TSC voting members
260276

261277
* [bar](https://github.com/bar) -
262278
**Bar User** &lt;[email protected]&gt; (she/her)

test/unit/collaborators.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ describe('collaborators', function() {
133133
});
134134

135135
it(
136-
'should throw error if there is no TSC Emeriti section in the README',
136+
'should throw error if there is no TSC Regular Members section in the README',
137137
async() => {
138138
const argv = { owner: 'nodejs', repo: 'node' };
139139
const request = mockRequest(readmeNoTscE, argv);
140140
await assertThrowsAsync(
141141
async() => getCollaborators(cli, request, argv),
142-
/Error: Couldn't find ### TSC Emeriti in the README/);
142+
/Error: Couldn't find #### TSC regular members in the README/);
143143
});
144144

145145
it('should throw error if there is no Collaborators section in the README',
@@ -159,7 +159,7 @@ describe('collaborators', function() {
159159
const request = mockRequest(readmeNoCollaboratorE, argv);
160160
await assertThrowsAsync(
161161
async() => getCollaborators(cli, request, argv),
162-
/Error: Couldn't find ### Collaborator Emeriti in the README/);
162+
/Error: Couldn't find ### Collaborator emeriti in the README/);
163163
});
164164

165165
it(

0 commit comments

Comments
 (0)