Skip to content

Commit

Permalink
tools: improve error detection in find-inactive-collaborators
Browse files Browse the repository at this point in the history
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 <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and targos committed Sep 4, 2021
1 parent ea5f204 commit 78de83c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tools/find-inactive-collaborators.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ async function getCollaboratorsFromReadme() {
crlfDelay: Infinity,
});
const returnedArray = [];
let processingCollaborators = false;
let foundCollaboratorHeading = false;
for await (const line of readmeText) {
const isCollaborator = processingCollaborators && line.length;
if (line === '### Collaborators') {
processingCollaborators = true;
}
if (line === '### Collaborator emeriti') {
processingCollaborators = false;
// If we've found the collaborator heading already, stop processing at the
// next heading.
if (foundCollaboratorHeading && line.startsWith('#')) {
break;
}

const isCollaborator = foundCollaboratorHeading && line.length;

if (line === '### Collaborators') {
foundCollaboratorHeading = true;
}
if (line.startsWith('**') && isCollaborator) {
const [, name, email] = /^\*\*([^*]+)\*\* &lt;(.+)&gt;/.exec(line);
const mailmap = await runGitCommand(
Expand All @@ -89,6 +92,11 @@ async function getCollaboratorsFromReadme() {
});
}
}

if (!foundCollaboratorHeading) {
throw new Error('Could not find Collaborator section of README');
}

return returnedArray;
}

Expand Down

0 comments on commit 78de83c

Please sign in to comment.