Skip to content

Commit

Permalink
tools: take co-authors into account in find-inactive-collaborators
Browse files Browse the repository at this point in the history
PR-URL: #52669
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ulises Gascón <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
  • Loading branch information
aduh95 authored and marco-ippolito committed May 3, 2024
1 parent a920489 commit c925bc1
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions tools/find-inactive-collaborators.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,10 @@ async function runGitCommand(cmd, mapFn) {
return Promise.race([errorHandler, Promise.resolve(returnValue)]);
}

// Get all commit authors during the time period.
const authors = await runGitCommand(
`git shortlog -n -s --email --since="${SINCE}" HEAD`,
(line) => line.trim().split('\t', 2)[1],
);

// Get all approving reviewers of landed commits during the time period.
const approvingReviewers = await runGitCommand(
`git log --since="${SINCE}" | egrep "^ Reviewed-By: "`,
(line) => /^ {4}Reviewed-By: ([^<]+)/.exec(line)[1].trim(),
// Get all commit contributors during the time period.
const contributors = await runGitCommand(
`git log --pretty='format:%aN <%aE>%n%(trailers:only,valueonly,key=Co-authored-by)%n%(trailers:only,valueonly,key=Reviewed-by)' --since="${SINCE}" HEAD`,
String,
);

async function getCollaboratorsFromReadme() {
Expand Down Expand Up @@ -185,13 +179,11 @@ const collaborators = await getCollaboratorsFromReadme();

if (verbose) {
console.log(`Since ${SINCE}:\n`);
console.log(`* ${authors.size.toLocaleString()} authors have made commits.`);
console.log(`* ${approvingReviewers.size.toLocaleString()} reviewers have approved landed commits.`);
console.log(`* ${contributors.size.toLocaleString()} contributors`);
console.log(`* ${collaborators.length.toLocaleString()} collaborators currently in the project.`);
}
const inactive = collaborators.filter((collaborator) =>
!authors.has(collaborator.mailmap) &&
!approvingReviewers.has(collaborator.name),
!contributors.has(collaborator.mailmap),
);

if (inactive.length) {
Expand Down

0 comments on commit c925bc1

Please sign in to comment.