Skip to content

Commit cec0482

Browse files
Trotttargos
authored andcommitted
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: #39362 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent d948148 commit cec0482

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

.github/workflows/find-inactive-collaborators.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ on:
77

88
workflow_dispatch:
99

10+
env:
11+
NODE_VERSION: 16.x
12+
NUM_COMMITS: 5000
13+
1014
jobs:
1115
find:
1216

1317
runs-on: ubuntu-latest
1418

1519
steps:
1620
- uses: actions/checkout@v2
17-
18-
- name: Install Node.js
21+
with:
22+
fetch-depth: ${{ env.NUM_COMMITS }}
23+
24+
- name: Use Node.js ${{ env.NODE_VERSION }}
1925
uses: actions/setup-node@v2
2026
with:
21-
node-version: 16.x
27+
node-version: ${{ env.NODE_VERSION }}
2228

2329
- name: Find inactive collaborators
24-
run: tools/find-inactive-collaborators.mjs '1 year ago'
30+
run: tools/find-inactive-collaborators.mjs ${{ env.NUM_COMMITS }}

tools/find-inactive-collaborators.mjs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import cp from 'node:child_process';
88
import fs from 'node:fs';
99
import readline from 'node:readline';
1010

11-
const SINCE = process.argv[2] || '6 months ago';
11+
const SINCE = +process.argv[2] || 5000;
1212

1313
async function runGitCommand(cmd, mapFn) {
1414
const childProcess = cp.spawn('/bin/sh', ['-c', cmd], {
@@ -36,19 +36,19 @@ async function runGitCommand(cmd, mapFn) {
3636

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

4343
// Get all commit landers during the time period.
4444
const landers = await runGitCommand(
45-
`git shortlog -n -s -c --since="${SINCE}"`,
45+
`git shortlog -n -s -c --max-count="${SINCE}" HEAD`,
4646
(line) => line.trim().split('\t', 2)[1]
4747
);
4848

4949
// Get all approving reviewers of landed commits during the time period.
5050
const approvingReviewers = await runGitCommand(
51-
`git log --since="${SINCE}" | egrep "^ Reviewed-By: "`,
51+
`git log --max-count="${SINCE}" | egrep "^ Reviewed-By: "`,
5252
(line) => /^ Reviewed-By: ([^<]+)/.exec(line)[1].trim()
5353
);
5454

@@ -78,10 +78,11 @@ async function retrieveCollaboratorsFromReadme() {
7878
// Get list of current collaborators from README.md.
7979
const collaborators = await retrieveCollaboratorsFromReadme();
8080

81-
console.log(`${authors.size.toLocaleString()} authors have made commits since ${SINCE}.`);
82-
console.log(`${landers.size.toLocaleString()} landers have landed commits since ${SINCE}.`);
83-
console.log(`${approvingReviewers.size.toLocaleString()} reviewers have approved landed commits since ${SINCE}.`);
84-
console.log(`${collaborators.length.toLocaleString()} collaborators currently in the project.`);
81+
console.log(`In the last ${SINCE} commits:\n`);
82+
console.log(`* ${authors.size.toLocaleString()} authors have made commits.`);
83+
console.log(`* ${landers.size.toLocaleString()} landers have landed commits.`);
84+
console.log(`* ${approvingReviewers.size.toLocaleString()} reviewers have approved landed commits.`);
85+
console.log(`* ${collaborators.length.toLocaleString()} collaborators currently in the project.`);
8586

8687
const inactive = collaborators.filter((collaborator) =>
8788
!authors.has(collaborator) &&
@@ -90,6 +91,6 @@ const inactive = collaborators.filter((collaborator) =>
9091
);
9192

9293
if (inactive.length) {
93-
console.log('\nInactive collaborators:');
94-
console.log(inactive.join('\n'));
94+
console.log('\nInactive collaborators:\n');
95+
console.log(inactive.map((name) => `* ${name}`).join('\n'));
9596
}

0 commit comments

Comments
 (0)