summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-03-02 12:37:11 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-03-06 00:04:55 +0100
commit713046d9eb12344a6b36846fe8b1a986cbb5fe97 (patch)
treea2f1931bbaae1418ec0262be4cf36b757563badc /tools
parenta132b8ae5cc928f98fcc87bec6c3cd0cd221632f (diff)
downloadandroid-node-v8-713046d9eb12344a6b36846fe8b1a986cbb5fe97.tar.gz
android-node-v8-713046d9eb12344a6b36846fe8b1a986cbb5fe97.tar.bz2
android-node-v8-713046d9eb12344a6b36846fe8b1a986cbb5fe97.zip
tools: add mailmap support for Co-authored-by tags
Support `.mailmap` for manually added `Author:` and `Co-authored-by:` tags. PR-URL: https://github.com/nodejs/node/pull/26383 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/update-authors.js41
1 files changed, 40 insertions, 1 deletions
diff --git a/tools/update-authors.js b/tools/update-authors.js
index 1c48eaec85..3d7fcb14b2 100755
--- a/tools/update-authors.js
+++ b/tools/update-authors.js
@@ -3,6 +3,7 @@
// Passing --dry will redirect output to stdout rather than write to 'AUTHORS'.
'use strict';
const { spawn } = require('child_process');
+const path = require('path');
const fs = require('fs');
const readline = require('readline');
@@ -22,6 +23,38 @@ else
output.write('# Authors ordered by first contribution.\n\n');
+const mailmap = new Map();
+{
+ const lines = fs.readFileSync(path.resolve(__dirname, '../', '.mailmap'),
+ { encoding: 'utf8' }).split('\n');
+ for (let line of lines) {
+ line = line.trim();
+ if (line.startsWith('#') || line === '') continue;
+
+ let match;
+ // Replaced Name <original@example.com>
+ if (match = line.match(/^([^<]+)\s+(<[^>]+>)$/)) {
+ mailmap.set(match[2], { author: match[1] });
+ // <replaced@example.com> <original@example.com>
+ } else if (match = line.match(/^<([^>]+)>\s+(<[^>]+>)$/)) {
+ mailmap.set(match[2], { email: match[1] });
+ // Replaced Name <replaced@example.com> <original@example.com>
+ } else if (match = line.match(/^([^<]+)\s+(<[^>]+>)\s+(<[^>]+>)$/)) {
+ mailmap.set(match[3], {
+ author: match[1], email: match[2]
+ });
+ // Replaced Name <replaced@example.com> Original Name <original@example.com>
+ } else if (match =
+ line.match(/^([^<]+)\s+(<[^>]+>)\s+([^<]+)\s+(<[^>]+>)$/)) {
+ mailmap.set(match[3] + '\0' + match[4], {
+ author: match[1], email: match[2]
+ });
+ } else {
+ console.warn('Unknown .mailmap format:', line);
+ }
+ }
+}
+
const seen = new Set();
// Support regular git author metadata, as well as `Author:` and
@@ -34,7 +67,13 @@ rl.on('line', (line) => {
const match = line.match(authorRe);
if (!match) return;
- const { author, email } = match.groups;
+ let { author, email } = match.groups;
+
+ const replacement = mailmap.get(author + '\0' + email) || mailmap.get(email);
+ if (replacement) {
+ ({ author, email } = { author, email, ...replacement });
+ }
+
if (seen.has(email) ||
/@chromium\.org/.test(email) ||
email === '<erik.corry@gmail.com>') {