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 c3a744f

Browse filesBrowse files
Trotttargos
authored andcommitted
tools: warn about duplicates when generating AUTHORS file
PR-URL: #40304 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
1 parent 6c091c7 commit c3a744f
Copy full SHA for c3a744f

File tree

Expand file treeCollapse file tree

1 file changed

+30
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+30
-0
lines changed
Open diff view settings
Collapse file

‎tools/update-authors.js‎

Copy file name to clipboardExpand all lines: tools/update-authors.js
+30Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class CaseIndifferentMap {
1111
_map = new Map();
1212

1313
get(key) { return this._map.get(key.toLowerCase()); }
14+
has(key) { return this._map.has(key.toLowerCase()); }
1415
set(key, value) { return this._map.set(key.toLowerCase(), value); }
1516
}
1617

@@ -64,6 +65,30 @@ const mailmap = new CaseIndifferentMap();
6465
}
6566
}
6667

68+
const previousAuthors = new CaseIndifferentMap();
69+
{
70+
const lines = fs.readFileSync(path.resolve(__dirname, '../', 'AUTHORS'),
71+
{ encoding: 'utf8' }).split('\n');
72+
for (let line of lines) {
73+
line = line.trim();
74+
if (line.startsWith('#') || line === '') continue;
75+
76+
let match;
77+
if (match = line.match(/^([^<]+)\s+(<[^>]+>)$/)) {
78+
const name = match[1];
79+
const email = match[2];
80+
if (previousAuthors.has(name)) {
81+
const emails = previousAuthors.get(name);
82+
emails.push(email);
83+
} else {
84+
previousAuthors.set(name, [email]);
85+
}
86+
} else {
87+
console.warn('Unknown AUTHORS format:', line);
88+
}
89+
}
90+
}
91+
6792
const seen = new Set();
6893

6994
// Support regular git author metadata, as well as `Author:` and
@@ -93,6 +118,11 @@ rl.on('line', (line) => {
93118

94119
seen.add(email);
95120
output.write(`${author} ${email}\n`);
121+
const duplicate = previousAuthors.get(author);
122+
if (duplicate && !duplicate.includes(email)) {
123+
console.warn('Author name already in AUTHORS file. Possible duplicate:');
124+
console.warn(` ${author} <${email}>`);
125+
}
96126
});
97127

98128
rl.on('close', () => {

0 commit comments

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