Skip to content

Commit

Permalink
tools: email matchin is case insensitive for .mailmap
Browse files Browse the repository at this point in the history
PR-URL: #39430
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and targos committed Sep 4, 2021
1 parent dfb77a5 commit f75224f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tools/update-authors.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,21 @@ const mailmap = new CaseIndifferentMap();
let match;
// Replaced Name <original@example.com>
if (match = line.match(/^([^<]+)\s+(<[^>]+>)$/)) {
mailmap.set(match[2], { author: match[1] });
mailmap.set(match[2].toLowerCase(), {
author: match[1], email: match[2]
});
// <replaced@example.com> <original@example.com>
} else if (match = line.match(/^<([^>]+)>\s+(<[^>]+>)$/)) {
mailmap.set(match[2], { email: match[1] });
mailmap.set(match[2].toLowerCase(), { email: match[1] });
// Replaced Name <replaced@example.com> <original@example.com>
} else if (match = line.match(/^([^<]+)\s+(<[^>]+>)\s+(<[^>]+>)$/)) {
mailmap.set(match[3], {
mailmap.set(match[3].toLowerCase(), {
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], {
mailmap.set(match[3] + '\0' + match[4].toLowerCase(), {
author: match[1], email: match[2]
});
} else {
Expand All @@ -75,8 +77,10 @@ rl.on('line', (line) => {
if (!match) return;

let { author, email } = match.groups;
const emailLower = email.toLowerCase();

const replacement = mailmap.get(author + '\0' + email) || mailmap.get(email);
const replacement =
mailmap.get(author + '\0' + emailLower) || mailmap.get(emailLower);
if (replacement) {
({ author, email } = { author, email, ...replacement });
}
Expand Down

0 comments on commit f75224f

Please sign in to comment.