2016-02-28 22:32:13 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generate the AUTHORS file combining existing AUTHORS file with
|
|
|
|
# git commit log.
|
|
|
|
#
|
2016-03-27 21:31:36 +00:00
|
|
|
# Usage: generate_authors.pl AUTHORS.src
|
2016-02-28 22:32:13 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Copyright 2016 Michael Mann (see AUTHORS file)
|
|
|
|
#
|
|
|
|
# Wireshark - Network traffic analyzer
|
|
|
|
# By Gerald Combs <gerald@wireshark.org>
|
|
|
|
# Copyright 1998 Gerald Combs
|
|
|
|
#
|
2018-03-06 14:31:02 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2016-02-28 22:32:13 +00:00
|
|
|
|
2021-11-04 02:15:15 +00:00
|
|
|
use v5.10;
|
|
|
|
|
2016-02-28 22:32:13 +00:00
|
|
|
use warnings;
|
|
|
|
use strict;
|
2021-11-04 02:15:15 +00:00
|
|
|
use open ':std', ':encoding(UTF-8)';
|
2016-02-28 22:32:13 +00:00
|
|
|
|
|
|
|
my $state = "";
|
|
|
|
my %contributors = ();
|
|
|
|
|
2021-11-04 21:11:28 +00:00
|
|
|
my $acknowledgements_heading = "= Acknowledgements =";
|
2016-02-28 22:32:13 +00:00
|
|
|
|
|
|
|
my $git_log_text = "
|
2018-08-17 17:33:45 +00:00
|
|
|
= From git log =
|
|
|
|
|
2016-02-28 22:32:13 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
# Perl trim function to remove whitespace from the start and end of the string
|
|
|
|
sub trim($)
|
|
|
|
{
|
|
|
|
my $string = shift;
|
|
|
|
$string =~ s/^\s+//;
|
|
|
|
$string =~ s/\s+$//;
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub parse_author_name {
|
|
|
|
my $full_name = $_[0];
|
2016-03-27 21:09:52 +00:00
|
|
|
my $email_key;
|
2016-02-28 22:32:13 +00:00
|
|
|
|
|
|
|
if ($full_name =~ /^([\w\.\-\'\x80-\xff]+(\s*[\w+\.\-\'\x80-\xff])*)\s+<([^>]*)>/) {
|
|
|
|
#Make an exception for Gerald because he's part of the header
|
|
|
|
if ($3 ne "gerald[AT]wireshark.org") {
|
2016-03-27 21:09:52 +00:00
|
|
|
$email_key = lc($3);
|
|
|
|
$contributors{$email_key} = $1;
|
2021-11-04 02:15:15 +00:00
|
|
|
say $full_name;
|
2016-02-28 22:32:13 +00:00
|
|
|
}
|
|
|
|
} elsif ($full_name =~ /^([\w\.\-\'\x80-\xff]+(\s*[\w+\.\-\'\x80-\xff])*)\s+\(/) {
|
|
|
|
$contributors{"<no_email>"} = $1;
|
2021-11-04 02:15:15 +00:00
|
|
|
say $full_name;
|
2016-02-28 22:32:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub parse_git_name {
|
|
|
|
my $full_name = $_[0];
|
|
|
|
my $name;
|
|
|
|
my $email;
|
2016-03-27 21:09:52 +00:00
|
|
|
my $email_key;
|
2016-03-05 04:23:59 +00:00
|
|
|
my $len;
|
2016-03-07 16:39:16 +00:00
|
|
|
my $ntab = 3;
|
2016-03-05 04:23:59 +00:00
|
|
|
my $line;
|
2016-02-28 22:32:13 +00:00
|
|
|
|
2016-03-04 17:55:40 +00:00
|
|
|
# 4321 Navin R. Johnson <nrjohnson@example.com>
|
|
|
|
if ($full_name =~ /^\s*\d+\s+([^<]*)\s*<([^>]*)>/) {
|
2016-03-05 04:23:59 +00:00
|
|
|
$name = trim($1);
|
2016-02-28 22:32:13 +00:00
|
|
|
#Convert real email address to "spam proof" one
|
2016-03-05 04:23:59 +00:00
|
|
|
$email = trim($2);
|
2016-03-07 14:35:21 +00:00
|
|
|
$email =~ s/@/[AT]/g;
|
2016-03-27 21:09:52 +00:00
|
|
|
$email_key = lc($email);
|
2016-02-28 22:32:13 +00:00
|
|
|
|
2016-03-27 21:09:52 +00:00
|
|
|
if (!exists($contributors{ $email_key })) {
|
2016-02-28 22:32:13 +00:00
|
|
|
#Make an exception for Gerald because he's part of the header
|
|
|
|
if ($email ne "gerald[AT]wireshark.org") {
|
2016-03-05 04:23:59 +00:00
|
|
|
$len = length $name;
|
2016-03-07 16:39:16 +00:00
|
|
|
if ($len >= 8 * $ntab) {
|
|
|
|
$line = "$name <$email>";
|
|
|
|
} else {
|
|
|
|
$ntab -= $len / 8;
|
|
|
|
$ntab +=1 if ($len % 8);
|
|
|
|
$line = $name . "\t" x $ntab . "<$email>";
|
|
|
|
}
|
2016-03-27 21:09:52 +00:00
|
|
|
$contributors{$email_key} = $1;
|
2021-11-04 02:15:15 +00:00
|
|
|
say $line;
|
2016-02-28 22:32:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# MAIN
|
|
|
|
#
|
|
|
|
|
|
|
|
open( my $author_fh, '<', $ARGV[0] ) or die "Can't open $ARGV[0]: $!";
|
2021-11-04 21:11:28 +00:00
|
|
|
|
2021-11-04 02:15:15 +00:00
|
|
|
while ( my $line = <$author_fh> ) {
|
2016-02-28 22:32:13 +00:00
|
|
|
chomp $line;
|
|
|
|
|
2021-11-04 21:11:28 +00:00
|
|
|
say $line;
|
2016-02-28 22:32:13 +00:00
|
|
|
|
2021-11-04 21:11:28 +00:00
|
|
|
last if $line eq "= Contributors =";
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( my $line = <$author_fh> ) {
|
|
|
|
chomp $line;
|
|
|
|
|
|
|
|
last if ($line eq $acknowledgements_heading);
|
2016-02-28 22:32:13 +00:00
|
|
|
|
|
|
|
if ($line =~ /([^\{]*)\{/) {
|
|
|
|
parse_author_name($line);
|
|
|
|
$state = "s_in_bracket";
|
|
|
|
} elsif ($state eq "s_in_bracket") {
|
|
|
|
if ($line =~ /([^\}]*)\}/) {
|
2021-11-04 02:15:15 +00:00
|
|
|
say $line;
|
2016-02-28 22:32:13 +00:00
|
|
|
$state = "";
|
|
|
|
} else {
|
2021-11-04 02:15:15 +00:00
|
|
|
say $line;
|
2016-02-28 22:32:13 +00:00
|
|
|
}
|
|
|
|
} elsif ($line =~ /</) {
|
|
|
|
parse_author_name($line);
|
|
|
|
} elsif ($line =~ "(e-mail address removed at contributor's request)") {
|
|
|
|
parse_author_name($line);
|
|
|
|
} else {
|
2021-11-04 02:15:15 +00:00
|
|
|
say $line;
|
2016-02-28 22:32:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print $git_log_text;
|
|
|
|
|
2016-03-27 21:31:36 +00:00
|
|
|
open( my $git_author_fh, 'git --no-pager shortlog -se HEAD|')
|
|
|
|
or die "Can't execute git shortlog: $!";
|
2016-02-28 22:32:13 +00:00
|
|
|
|
2021-11-04 02:15:15 +00:00
|
|
|
while ( my $git_line = <$git_author_fh> ) {
|
2016-02-28 22:32:13 +00:00
|
|
|
chomp $git_line;
|
|
|
|
|
|
|
|
parse_git_name($git_line);
|
|
|
|
}
|
|
|
|
close $git_author_fh;
|
|
|
|
|
2021-11-04 21:11:28 +00:00
|
|
|
print "\n\n";
|
|
|
|
|
|
|
|
say $acknowledgements_heading;
|
|
|
|
|
|
|
|
while ( my $line = <$author_fh> ) {
|
|
|
|
chomp $line;
|
|
|
|
say $line;
|
|
|
|
}
|
|
|
|
|
|
|
|
close $author_fh;
|
2016-02-28 22:32:13 +00:00
|
|
|
|
|
|
|
__END__
|