mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
tools: change commit fetch limiting in find-inactive-collaborators
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 <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
@@ -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 }}
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user