2 # Maintainers.pm - show information about maintainers
11 require "Maintainers.pl";
12 use vars qw(%Modules %Maintainers);
14 use vars qw(@ISA @EXPORT_OK);
16 @EXPORT_OK = qw(%Modules %Maintainers
17 get_module_files get_module_pat
18 show_results process_options);
25 if (open(MANIFEST, "MANIFEST")) {
27 if (/^(\S+)\t+(.+)$/) {
33 die "$0: Failed to open MANIFEST for reading: $!\n";
38 split ' ', $Modules{$m}{FILES};
41 sub get_module_files {
43 sort { lc $a cmp lc $b }
45 -f $_ ? # Files as-is.
47 -d _ ? # Recurse into directories.
52 push @files, $File::Find::name
53 if -f $_ && exists $MANIFEST{$File::Find::name};
57 : glob($_) # The rest are globbable patterns.
61 sub get_maintainer_modules {
63 sort { lc $a cmp lc $b }
64 grep { $Modules{$_}{MAINTAINER} eq $m }
70 $0: Usage: $0 [[--maintainer M --module M --files]|file ...]
71 --maintainer M list all maintainers matching M
72 --module M list all modules matching M
73 --files list all files
74 Matching is case-ignoring regexp, author matching is both by
75 the short id and by the full name and email. A "module" may
76 not be just a module, it may be a file or files or a subdirectory.
77 The options may be abbreviated to their unique prefixes
90 'maintainer=s' => \$Maintainer,
91 'module=s' => \$Module,
97 usage() if @Files && ($Maintainer || $Module || $Files);
99 for my $mean ($Maintainer, $Module) {
100 warn "$0: Did you mean '$0 $mean'?\n"
101 if $mean && -e $mean && $mean ne '.' && !$Files;
104 warn "$0: Did you mean '$0 -mo $Maintainer'?\n"
105 if defined $Maintainer && exists $Modules{$Maintainer};
107 warn "$0: Did you mean '$0 -ma $Module'?\n"
108 if defined $Module && exists $Maintainers{$Module};
110 return ($Maintainer, $Module, $Files, @Files);
114 my ($Maintainer, $Module, $Files, @Files) = @_;
117 for my $m (sort keys %Maintainers) {
118 if ($m =~ /$Maintainer/io || $Maintainers{$m} =~ /$Maintainer/io) {
119 my @modules = get_maintainer_modules($m);
121 @modules = grep { /$Module/io } @modules;
125 for my $module (@modules) {
126 push @files, get_module_files($module);
128 printf "%-15s @files\n", $m;
131 printf "%-15s @modules\n", $m;
133 printf "%-15s $Maintainers{$m}\n", $m;
139 for my $m (sort { lc $a cmp lc $b } keys %Modules) {
140 if ($m =~ /$Module/io) {
142 my @files = get_module_files($m);
143 printf "%-15s @files\n", $m;
145 printf "%-15s $Modules{$m}{MAINTAINER}\n", $m;
152 for (@Files) { s:^\./:: }
154 @ModuleByFile{@Files} = ();
156 # First try fast match.
159 for my $module (keys %Modules) {
160 for my $pat (get_module_pat($module)) {
161 $ModuleByPat{$pat} = $module;
166 for my $pat (keys %ModuleByPat) {
168 $ExpModuleByPat{$pat} = $ModuleByPat{$pat};
170 for my $exp (glob($pat)) {
171 $ExpModuleByPat{$exp} = $ModuleByPat{$pat};
175 %ModuleByPat = %ExpModuleByPat;
176 for my $file (@Files) {
177 $ModuleByFile{$file} = $ModuleByPat{$file}
178 if exists $ModuleByPat{$file};
181 # If still unresolved files...
182 if (my @ToDo = grep { !defined $ModuleByFile{$_} } keys %ModuleByFile) {
184 # Cannot match what isn't there.
185 @ToDo = grep { -e $_ } @ToDo;
188 # Try prefix matching.
190 # Remove trailing slashes.
191 for (@ToDo) { s|/$|| }
196 for my $pat (keys %ModuleByPat) {
197 last unless keys %ToDo;
200 for my $file (keys %ToDo) {
201 if ($file =~ m|^$pat|i) {
202 $ModuleByFile{$file} = $ModuleByPat{$pat};
212 for my $file (@Files) {
213 if (defined $ModuleByFile{$file}) {
214 my $module = $ModuleByFile{$file};
215 my $maintainer = $Modules{$ModuleByFile{$file}}{MAINTAINER};
216 printf "%-15s $module $maintainer $Maintainers{$maintainer}\n", $file;
218 printf "%-15s ?\n", $file;