Make mkauthors/mkheaders respect the mailmap for coauthors.

This commit is contained in:
Sadie Powell 2024-09-02 11:16:13 +01:00
parent faa96b7956
commit 266cc6c3c3
2 changed files with 15 additions and 6 deletions

View File

@ -30,14 +30,23 @@ use lib dirname $RealDir;
use make::common; use make::common;
use make::console; use make::console;
my %committers;
for my $committer (split /\n+/, `git log --pretty='%an <%ae>%n%(trailers:key=Co-Authored-By,valueonly)' HEAD`) {
$committers{$committer} ||= 0;
$committers{$committer} += 1;
}
my %authors; my %authors;
for my $author (split /\n+/, `git log --pretty='%aN <%aE>%n%(trailers:key=Co-Authored-By,valueonly)' HEAD`) { for my $committer (keys %committers) {
open(my $fh, '-|', 'git', 'check-mailmap', $committer);
chomp(my $author = <$fh>);
close $fh;
$author = $1 if $author =~ /^(.+) <(?:unknown\@email.invalid|\S+\@users.noreply.github.com)>$/; $author = $1 if $author =~ /^(.+) <(?:unknown\@email.invalid|\S+\@users.noreply.github.com)>$/;
next if $author =~ /\[bot\]$/; next if $author =~ /\[bot\]$/;
$author =~ s/\.$//g;
$authors{$author} ||= 0; $authors{$author} ||= 0;
$authors{$author} += 1; $authors{$author} += $committers{$committer};
} }
my $author_file = catfile dirname($RealDir), 'docs', 'AUTHORS.txt'; my $author_file = catfile dirname($RealDir), 'docs', 'AUTHORS.txt';

View File

@ -33,10 +33,8 @@ use make::common;
use make::console; use make::console;
my @ignored_revisions = ( my @ignored_revisions = (
'0b4285abd12323920d92fee51e199edd7527dbec', # adding copyright headers
'46a39046196f55b52336e19662bb7bac85b731ac', # adding copyright headers '46a39046196f55b52336e19662bb7bac85b731ac', # adding copyright headers
'4a6fedd9324d87349a806c9c1d0ae6e7d3c1fd38', # mass-updating descriptions '4a6fedd9324d87349a806c9c1d0ae6e7d3c1fd38', # mass-updating descriptions
'56375392ba94f2552bbeeeab4fd39e1e50295525', # sadie's name change
'bab14f0dd2345c9d7dcbc47c918563709e1ac094', # peavey breaking line endings 'bab14f0dd2345c9d7dcbc47c918563709e1ac094', # peavey breaking line endings
'de6d4dbd1e8845e08c2d87cd89a919e5b21ba619', # jsoref fixing a ton of typos 'de6d4dbd1e8845e08c2d87cd89a919e5b21ba619', # jsoref fixing a ton of typos
'f2acdbc3820f0f4f5ef76a0a64e73d2a320df91f', # peavey fixing line endings 'f2acdbc3820f0f4f5ef76a0a64e73d2a320df91f', # peavey fixing line endings
@ -123,7 +121,9 @@ for my $path (@paths) {
push @{$authors{$display}}, $commits{$commit}->{YEAR}; push @{$authors{$display}}, $commits{$commit}->{YEAR};
my $details = `git rev-list --format=%B --max-count=1 $commit`; my $details = `git rev-list --format=%B --max-count=1 $commit`;
while ($details =~ /co-authored-by: ([^<]+<[^>]+>)/gi) { while ($details =~ /co-authored-by: ([^<]+<[^>]+>)/gi) {
my $coauthor = $1; open(my $fh, '-|', 'git', 'check-mailmap', $1);
chomp(my $coauthor = <$fh>);
close $fh;
my $year = $details =~ /co-authored-year: (\d+)/i ? $1 : $commits{$commit}->{YEAR}; my $year = $details =~ /co-authored-year: (\d+)/i ? $1 : $commits{$commit}->{YEAR};
$authors{$coauthor} //= []; $authors{$coauthor} //= [];
push @{$authors{$coauthor}}, $year; push @{$authors{$coauthor}}, $year;