Skip to content

Commit

Permalink
get_maintainer: add email addresses from .yaml files
Browse files Browse the repository at this point in the history
.yaml files can contain maintainer/author addresses and it seems unlikely
or unnecessary that individual MAINTAINER file section entries for each
.yaml file will be created.

So add the email addresses found in .yaml files to the default
get_maintainer output.

The email addresses are marked with "(in file)" when using the "--roles"
or "--rolestats" options.

Miscellanea:

o Change $file_emails to $email_file_emails to avoid visual
  naming conflicts with @file_emails

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Tested-by: Sam Ravnborg <[email protected]>
Acked-by: Sam Ravnborg <[email protected]>
Link: http://lkml.kernel.org/r/e85006456d9dbae55286c67ac5263668a72f5b58.1588022228.git.joe@perches.com
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed Jun 5, 2020
1 parent de83dbd commit 0c78c01
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions scripts/get_maintainer.pl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
my $letters = "";
my $keywords = 1;
my $sections = 0;
my $file_emails = 0;
my $email_file_emails = 0;
my $from_filename = 0;
my $pattern_depth = 0;
my $self_test = undef;
Expand All @@ -69,6 +69,12 @@

my $exit = 0;

my @files = ();
my @fixes = (); # If a patch description includes Fixes: lines
my @range = ();
my @keyword_tvi = ();
my @file_emails = ();

my %commit_author_hash;
my %commit_signer_hash;

Expand Down Expand Up @@ -266,7 +272,7 @@
'pattern-depth=i' => \$pattern_depth,
'k|keywords!' => \$keywords,
'sections!' => \$sections,
'fe|file-emails!' => \$file_emails,
'fe|file-emails!' => \$email_file_emails,
'f|file' => \$from_filename,
'find-maintainer-files' => \$find_maintainer_files,
'mpath|maintainer-path=s' => \$maintainer_path,
Expand Down Expand Up @@ -424,6 +430,22 @@ sub read_all_maintainer_files {
}
}

sub maintainers_in_file {
my ($file) = @_;

return if ($file =~ m@\bMAINTAINERS$@);

if (-f $file && ($email_file_emails || $file =~ /\.yaml$/)) {
open(my $f, '<', $file)
or die "$P: Can't open $file: $!\n";
my $text = do { local($/) ; <$f> };
close($f);

my @poss_addr = $text =~ m$[A-Za-zÀ-ÿ\"\' \,\.\+-]*\s*[\,]*\s*[\(\<\{]{0,1}[A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+\.[A-Za-z0-9]+[\)\>\}]{0,1}$g;
push(@file_emails, clean_file_emails(@poss_addr));
}
}

#
# Read mail address map
#
Expand Down Expand Up @@ -504,12 +526,6 @@ sub read_mailmap {

## use the filenames on the command line or find the filenames in the patchfiles

my @files = ();
my @fixes = (); # If a patch description includes Fixes: lines
my @range = ();
my @keyword_tvi = ();
my @file_emails = ();

if (!@ARGV) {
push(@ARGV, "&STDIN");
}
Expand All @@ -527,7 +543,7 @@ sub read_mailmap {
$file =~ s/^\Q${cur_path}\E//; #strip any absolute path
$file =~ s/^\Q${lk_path}\E//; #or the path to the lk tree
push(@files, $file);
if ($file ne "MAINTAINERS" && -f $file && ($keywords || $file_emails)) {
if ($file ne "MAINTAINERS" && -f $file && $keywords) {
open(my $f, '<', $file)
or die "$P: Can't open $file: $!\n";
my $text = do { local($/) ; <$f> };
Expand All @@ -539,10 +555,6 @@ sub read_mailmap {
}
}
}
if ($file_emails) {
my @poss_addr = $text =~ m$[A-Za-zÀ-ÿ\"\' \,\.\+-]*\s*[\,]*\s*[\(\<\{]{0,1}[A-Za-z0-9_\.\+-]+\@[A-Za-z0-9\.-]+\.[A-Za-z0-9]+[\)\>\}]{0,1}$g;
push(@file_emails, clean_file_emails(@poss_addr));
}
}
} else {
my $file_cnt = @files;
Expand Down Expand Up @@ -923,6 +935,8 @@ sub get_maintainers {
print("\n");
}
}

maintainers_in_file($file);
}

if ($keywords) {
Expand Down Expand Up @@ -1835,7 +1849,7 @@ sub interactive_get_maintainers {
tg toggle git entries
tl toggle open list entries
ts toggle subscriber list entries
f emails in file [$file_emails]
f emails in file [$email_file_emails]
k keywords in file [$keywords]
r remove duplicates [$email_remove_duplicates]
p# pattern match depth [$pattern_depth]
Expand Down Expand Up @@ -1960,7 +1974,7 @@ sub interactive_get_maintainers {
bool_invert(\$email_git_all_signature_types);
$rerun = 1;
} elsif ($sel eq "f") {
bool_invert(\$file_emails);
bool_invert(\$email_file_emails);
$rerun = 1;
} elsif ($sel eq "r") {
bool_invert(\$email_remove_duplicates);
Expand Down

0 comments on commit 0c78c01

Please sign in to comment.