Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(git-node): update README parser to account the recent TSC changes #688

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/collaborators.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import fs from 'node:fs';

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

const TSC = 'TSC';
Expand Down Expand Up @@ -73,13 +74,17 @@ function parseCollaborators(readme, cli) {
let m;

const tscIndex = readme.toUpperCase().indexOf(TSC_TITLE.toUpperCase());
const tscrIndex = readme.toUpperCase().indexOf(TSC_REGULAR_TITLE.toUpperCase());
const tsceIndex = readme.toUpperCase().indexOf(TSCE_TITLE.toUpperCase());
const clIndex = readme.toUpperCase().indexOf(CL_TITLE.toUpperCase());
const cleIndex = readme.toUpperCase().indexOf(CLE_TITLE.toUpperCase());

if (tscIndex === -1) {
throw new Error(`Couldn't find ${TSC_TITLE} in the README`);
}
if (tscrIndex === -1) {
throw new Error(`Couldn't find ${TSC_REGULAR_TITLE} in the README`);
}
if (tsceIndex === -1) {
throw new Error(`Couldn't find ${TSCE_TITLE} in the README`);
}
Expand All @@ -90,7 +95,8 @@ function parseCollaborators(readme, cli) {
throw new Error(`Couldn't find ${CLE_TITLE} in the README`);
}

if (!(tscIndex < tsceIndex &&
if (!(tscIndex < tscrIndex &&
tscrIndex < tsceIndex &&
tsceIndex < clIndex &&
clIndex < cleIndex)) {
cli.warn('Contacts in the README is out of order, ' +
Expand All @@ -100,7 +106,7 @@ function parseCollaborators(readme, cli) {
// We also assume that TSC & TSC Emeriti are also listed as collaborators
CONTACT_RE.lastIndex = tscIndex;
// eslint-disable-next-line no-cond-assign
while ((m = CONTACT_RE.exec(readme)) && CONTACT_RE.lastIndex < tsceIndex) {
while ((m = CONTACT_RE.exec(readme)) && CONTACT_RE.lastIndex < tscrIndex) {
const login = m[1].toLowerCase();
const user = new Collaborator(m[1], m[2], m[3], TSC);
collaborators.set(login, user);
Expand Down
23 changes: 21 additions & 2 deletions test/fixtures/README/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,26 @@ For more information about the governance of the Node.js project, see

### TSC (Technical Steering Committee)

#### TSC voting members

* [bar](https://github.com/bar) -
**Bar User** <<[email protected]>> (she/her)

### TSC emeriti
#### TSC regular members

* [Baz](https://github.com/Baz) -
**Baz User** &lt;[email protected]&gt; (he/him)

<details>

<summary>TSC emeriti members</summary>

#### TSC emeriti members

* [test](https://github.com/test) -
**Test** &lt;[email protected]&gt;
**Test User** <<[email protected]>>

</details>

### Collaborators

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

<details>

<summary>Emeriti</summary>

### Collaborator emeriti

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

</details>

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

Expand Down
20 changes: 18 additions & 2 deletions test/fixtures/README/README_alternative.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,20 @@ For more information about the governance of the Node.js project, see

### TSC (Technical Steering Committee)

#### TSC voting members

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

### TSC Emeriti
#### TSC regular members

<details>

<summary>TSC emeriti members</summary>

#### TSC emeriti members

</details>

### Collaborators

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

### Collaborator Emeriti
<details>

<summary>Emeriti</summary>

### Collaborator emeriti

</details>

Collaborators follow the [COLLABORATOR_GUIDE.md](./COLLABORATOR_GUIDE.md) in
maintaining the Node.js project.
Expand Down
18 changes: 16 additions & 2 deletions test/fixtures/README/README_no_TSC.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,19 @@ that forms the _Technical Steering Committee_ (TSC) which governs the project.
For more information about the governance of the Node.js project, see
[GOVERNANCE.md](./GOVERNANCE.md).

### TSC Emeriti
### TSC (Technical Steering Committee)

<details>

<summary>TSC emeriti members</summary>

#### TSC emeriti members

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

</details>

### Collaborators

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

### Collaborator Emeriti
<details>

<summary>Emeriti</summary>

### Collaborator emeriti

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

</details>

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

Expand Down
10 changes: 9 additions & 1 deletion test/fixtures/README/README_no_TSCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ For more information about the governance of the Node.js project, see

### TSC (Technical Steering Committee)

#### TSC voting members

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

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

### Collaborator Emeriti
<details>

<summary>Emeriti</summary>

### Collaborator emeriti

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

</details>

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

Expand Down
12 changes: 11 additions & 1 deletion test/fixtures/README/README_no_collaboratorE.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,24 @@ For more information about the governance of the Node.js project, see

### TSC (Technical Steering Committee)

#### TSC voting members

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

### TSC Emeriti
#### TSC regular members

<details>

<summary>TSC emeriti members</summary>

#### TSC emeriti members

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

</details>

### Collaborators

* [bar](https://github.com/bar) -
Expand Down
20 changes: 18 additions & 2 deletions test/fixtures/README/README_no_collaborators.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,35 @@ For more information about the governance of the Node.js project, see

### TSC (Technical Steering Committee)

#### TSC voting members

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

### TSC Emeriti
#### TSC regular members

<details>

<summary>TSC emeriti members</summary>

#### TSC emeriti members

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

### Collaborator Emeriti
</details>

<details>

<summary>Emeriti</summary>

### Collaborator emeriti

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

</details>

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

Expand Down
22 changes: 19 additions & 3 deletions test/fixtures/README/README_unordered.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,17 @@ that forms the _Technical Steering Committee_ (TSC) which governs the project.
For more information about the governance of the Node.js project, see
[GOVERNANCE.md](./GOVERNANCE.md).

### Collaborator Emeriti
<details>

<summary>Emeriti</summary>

### Collaborator emeriti

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

</details>

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

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

### TSC Emeriti
### TSC (Technical Steering Committee)

<details>

<summary>Emeriti</summary>

#### TSC emeriti members

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

### TSC (Technical Steering Committee)
</details>

#### TSC regular members

#### TSC voting members

* [bar](https://github.com/bar) -
**Bar User** &lt;[email protected]&gt; (she/her)
Expand Down
6 changes: 3 additions & 3 deletions test/unit/collaborators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ describe('collaborators', function() {
});

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

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

it(
Expand Down