Skip to content

Commit b1b6f20

Browse files
Trottdanielleadams
authored andcommitted
tools: improve error detection in find-inactive-collaborators
Previously, if the script failed to find a collaborator section in the README file, it would carry on with no results and no error. This detects the problem and throws an error. It is also more robust in that it will still work if the emeriti section ends up getting moved and does not immedaitely follow the collaborator section. PR-URL: #39617 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 793fee4 commit b1b6f20

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

tools/find-inactive-collaborators.mjs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,19 @@ async function getCollaboratorsFromReadme() {
6464
crlfDelay: Infinity,
6565
});
6666
const returnedArray = [];
67-
let processingCollaborators = false;
67+
let foundCollaboratorHeading = false;
6868
for await (const line of readmeText) {
69-
const isCollaborator = processingCollaborators && line.length;
70-
if (line === '### Collaborators') {
71-
processingCollaborators = true;
72-
}
73-
if (line === '### Collaborator emeriti') {
74-
processingCollaborators = false;
69+
// If we've found the collaborator heading already, stop processing at the
70+
// next heading.
71+
if (foundCollaboratorHeading && line.startsWith('#')) {
7572
break;
7673
}
74+
75+
const isCollaborator = foundCollaboratorHeading && line.length;
76+
77+
if (line === '### Collaborators') {
78+
foundCollaboratorHeading = true;
79+
}
7780
if (line.startsWith('**') && isCollaborator) {
7881
const [, name, email] = /^\*\*([^*]+)\*\* &lt;(.+)&gt;/.exec(line);
7982
const mailmap = await runGitCommand(
@@ -89,6 +92,11 @@ async function getCollaboratorsFromReadme() {
8992
});
9093
}
9194
}
95+
96+
if (!foundCollaboratorHeading) {
97+
throw new Error('Could not find Collaborator section of README');
98+
}
99+
92100
return returnedArray;
93101
}
94102

0 commit comments

Comments
 (0)