Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b2abeff

Browse filesBrowse files
addaleaxtargos
authored andcommitted
tools: implement update-authors in JS
Replace the previous Perl script with a Node.js variant that explicitly supports `Author:` and, in particular, GitHub’s standard `Co-authored-by:` metadata tags. PR-URL: #22771 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent a96a846 commit b2abeff
Copy full SHA for b2abeff

File tree

Expand file treeCollapse file tree

2 files changed

+50
-22
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+50
-22
lines changed
Open diff view settings
Collapse file

‎tools/update-authors.js‎

Copy file name to clipboard
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env node
2+
// Usage: tools/update-author.js [--dry]
3+
// Passing --dry will redirect output to stdout rather than write to 'AUTHORS'.
4+
'use strict';
5+
const { spawn } = require('child_process');
6+
const fs = require('fs');
7+
const readline = require('readline');
8+
9+
const log = spawn(
10+
'git',
11+
// Inspect author name/email and body.
12+
['log', '--reverse', '--format=Author: %aN <%aE>\n%b'], {
13+
stdio: ['inherit', 'pipe', 'inherit']
14+
});
15+
const rl = readline.createInterface({ input: log.stdout });
16+
17+
let output;
18+
if (process.argv.includes('--dry'))
19+
output = process.stdout;
20+
else
21+
output = fs.createWriteStream('AUTHORS');
22+
23+
output.write('# Authors ordered by first contribution.\n\n');
24+
25+
const seen = new Set();
26+
27+
// Support regular git author metadata, as well as `Author:` and
28+
// `Co-authored-by:` in the message body. Both have been used in the past
29+
// to indicate multiple authors per commit, with the latter standardized
30+
// by GitHub now.
31+
const authorRe =
32+
/(^Author:|^Co-authored-by:)\s+(?<author>[^<]+)\s+(?<email><[^>]+>)/i;
33+
rl.on('line', (line) => {
34+
const match = line.match(authorRe);
35+
if (!match) return;
36+
37+
const { author, email } = match.groups;
38+
if (seen.has(email) ||
39+
/@chromium\.org/.test(email) ||
40+
email === '<erik.corry@gmail.com>') {
41+
return;
42+
}
43+
44+
seen.add(email);
45+
output.write(`${author} ${email}\n`);
46+
});
47+
48+
rl.on('close', () => {
49+
output.end('\n# Generated by tools/update-authors.js\n');
50+
});
Collapse file

‎tools/update-authors.sh‎

Copy file name to clipboardExpand all lines: tools/update-authors.sh
-22Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.