From dbd4bbcf35bed4a92f1737e31474dc1c7a833d2d Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 12 Jul 2021 09:22:27 -0700 Subject: [PATCH] tools: change commit fetch limiting in find-inactive-collaborators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub Action workflows can be told to clone a certain number of commits or else everything. Change find-inactive-collaborators to take a number of commits to examine rather than a date range so that the parameter can be used in GitHub Actions. PR-URL: https://github.com/nodejs/node/pull/39362 Reviewed-By: Michaƫl Zasso Reviewed-By: Antoine du Hamel --- .../workflows/find-inactive-collaborators.yml | 14 +++++++++---- tools/find-inactive-collaborators.mjs | 21 ++++++++++--------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/find-inactive-collaborators.yml b/.github/workflows/find-inactive-collaborators.yml index b975fb340308d3..45b3a8cebcd350 100644 --- a/.github/workflows/find-inactive-collaborators.yml +++ b/.github/workflows/find-inactive-collaborators.yml @@ -7,6 +7,10 @@ on: workflow_dispatch: +env: + NODE_VERSION: 16.x + NUM_COMMITS: 5000 + jobs: find: @@ -14,11 +18,13 @@ jobs: steps: - uses: actions/checkout@v2 - - - name: Install Node.js + with: + fetch-depth: ${{ env.NUM_COMMITS }} + + - name: Use Node.js ${{ env.NODE_VERSION }} uses: actions/setup-node@v2 with: - node-version: 16.x + node-version: ${{ env.NODE_VERSION }} - name: Find inactive collaborators - run: tools/find-inactive-collaborators.mjs '1 year ago' + run: tools/find-inactive-collaborators.mjs ${{ env.NUM_COMMITS }} diff --git a/tools/find-inactive-collaborators.mjs b/tools/find-inactive-collaborators.mjs index 578adf05fb78c7..2951d81c534696 100755 --- a/tools/find-inactive-collaborators.mjs +++ b/tools/find-inactive-collaborators.mjs @@ -8,7 +8,7 @@ import cp from 'node:child_process'; import fs from 'node:fs'; import readline from 'node:readline'; -const SINCE = process.argv[2] || '6 months ago'; +const SINCE = +process.argv[2] || 5000; async function runGitCommand(cmd, mapFn) { const childProcess = cp.spawn('/bin/sh', ['-c', cmd], { @@ -36,19 +36,19 @@ async function runGitCommand(cmd, mapFn) { // Get all commit authors during the time period. const authors = await runGitCommand( - `git shortlog -n -s --since="${SINCE}"`, + `git shortlog -n -s --max-count="${SINCE}" HEAD`, (line) => line.trim().split('\t', 2)[1] ); // Get all commit landers during the time period. const landers = await runGitCommand( - `git shortlog -n -s -c --since="${SINCE}"`, + `git shortlog -n -s -c --max-count="${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: "`, + `git log --max-count="${SINCE}" | egrep "^ Reviewed-By: "`, (line) => /^ Reviewed-By: ([^<]+)/.exec(line)[1].trim() ); @@ -78,10 +78,11 @@ async function retrieveCollaboratorsFromReadme() { // Get list of current collaborators from README.md. const collaborators = await retrieveCollaboratorsFromReadme(); -console.log(`${authors.size.toLocaleString()} authors have made commits since ${SINCE}.`); -console.log(`${landers.size.toLocaleString()} landers have landed commits since ${SINCE}.`); -console.log(`${approvingReviewers.size.toLocaleString()} reviewers have approved landed commits since ${SINCE}.`); -console.log(`${collaborators.length.toLocaleString()} collaborators currently in the project.`); +console.log(`In the last ${SINCE} commits:\n`); +console.log(`* ${authors.size.toLocaleString()} authors have made commits.`); +console.log(`* ${landers.size.toLocaleString()} landers have landed commits.`); +console.log(`* ${approvingReviewers.size.toLocaleString()} reviewers have approved landed commits.`); +console.log(`* ${collaborators.length.toLocaleString()} collaborators currently in the project.`); const inactive = collaborators.filter((collaborator) => !authors.has(collaborator) && @@ -90,6 +91,6 @@ const inactive = collaborators.filter((collaborator) => ); if (inactive.length) { - console.log('\nInactive collaborators:'); - console.log(inactive.join('\n')); + console.log('\nInactive collaborators:\n'); + console.log(inactive.map((name) => `* ${name}`).join('\n')); }