diff options
author | Rich Trott <rtrott@gmail.com> | 2021-10-04 01:07:14 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2021-10-09 18:05:11 +0300 |
commit | d6d6b050ffa277a22166314be2b859df967432c4 (patch) | |
tree | ba43ca7513192005acc98bb14e5154cb9ed65986 | |
parent | 0d50dfdf61527b8f9f0e70885cefaae23963c0a8 (diff) |
tools: warn about duplicates when generating AUTHORS file
PR-URL: https://github.com/nodejs/node/pull/40304
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
-rwxr-xr-x | tools/update-authors.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/update-authors.js b/tools/update-authors.js index f9797b1998c..4ba73f28c9a 100755 --- a/tools/update-authors.js +++ b/tools/update-authors.js @@ -11,6 +11,7 @@ class CaseIndifferentMap { _map = new Map(); get(key) { return this._map.get(key.toLowerCase()); } + has(key) { return this._map.has(key.toLowerCase()); } set(key, value) { return this._map.set(key.toLowerCase(), value); } } @@ -64,6 +65,30 @@ const mailmap = new CaseIndifferentMap(); } } +const previousAuthors = new CaseIndifferentMap(); +{ + const lines = fs.readFileSync(path.resolve(__dirname, '../', 'AUTHORS'), + { encoding: 'utf8' }).split('\n'); + for (let line of lines) { + line = line.trim(); + if (line.startsWith('#') || line === '') continue; + + let match; + if (match = line.match(/^([^<]+)\s+(<[^>]+>)$/)) { + const name = match[1]; + const email = match[2]; + if (previousAuthors.has(name)) { + const emails = previousAuthors.get(name); + emails.push(email); + } else { + previousAuthors.set(name, [email]); + } + } else { + console.warn('Unknown AUTHORS format:', line); + } + } +} + const seen = new Set(); // Support regular git author metadata, as well as `Author:` and @@ -93,6 +118,11 @@ rl.on('line', (line) => { seen.add(email); output.write(`${author} ${email}\n`); + const duplicate = previousAuthors.get(author); + if (duplicate && !duplicate.includes(email)) { + console.warn('Author name already in AUTHORS file. Possible duplicate:'); + console.warn(` ${author} <${email}>`); + } }); rl.on('close', () => { |