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 --check]|file ...]
71 --maintainer M list all maintainers matching M
72 --module M list all modules matching M
73 --files list all files
74 --check check consistency of Maintainers.pl
75 Matching is case-ignoring regexp, author matching is both by
76 the short id and by the full name and email. A "module" may
77 not be just a module, it may be a file or files or a subdirectory.
78 The options may be abbreviated to their unique prefixes
92 'maintainer=s' => \$Maintainer,
93 'module=s' => \$Module,
100 usage() if @Files && ($Maintainer || $Module || $Files);
102 for my $mean ($Maintainer, $Module) {
103 warn "$0: Did you mean '$0 $mean'?\n"
104 if $mean && -e $mean && $mean ne '.' && !$Files;
107 warn "$0: Did you mean '$0 -mo $Maintainer'?\n"
108 if defined $Maintainer && exists $Modules{$Maintainer};
110 warn "$0: Did you mean '$0 -ma $Module'?\n"
111 if defined $Module && exists $Maintainers{$Module};
113 return ($Maintainer, $Module, $Files, @Files);
117 my ($Maintainer, $Module, $Files, @Files) = @_;
120 for my $m (sort keys %Maintainers) {
121 if ($m =~ /$Maintainer/io || $Maintainers{$m} =~ /$Maintainer/io) {
122 my @modules = get_maintainer_modules($m);
124 @modules = grep { /$Module/io } @modules;
128 for my $module (@modules) {
129 push @files, get_module_files($module);
131 printf "%-15s @files\n", $m;
134 printf "%-15s @modules\n", $m;
136 printf "%-15s $Maintainers{$m}\n", $m;
142 for my $m (sort { lc $a cmp lc $b } keys %Modules) {
143 if ($m =~ /$Module/io) {
145 my @files = get_module_files($m);
146 printf "%-15s @files\n", $m;
148 printf "%-15s $Modules{$m}{MAINTAINER}\n", $m;
155 for (@Files) { s:^\./:: }
157 @ModuleByFile{@Files} = ();
159 # First try fast match.
162 for my $module (keys %Modules) {
163 for my $pat (get_module_pat($module)) {
164 $ModuleByPat{$pat} = $module;
169 for my $pat (keys %ModuleByPat) {
171 $ExpModuleByPat{$pat} = $ModuleByPat{$pat};
173 for my $exp (glob($pat)) {
174 $ExpModuleByPat{$exp} = $ModuleByPat{$pat};
178 %ModuleByPat = %ExpModuleByPat;
179 for my $file (@Files) {
180 $ModuleByFile{$file} = $ModuleByPat{$file}
181 if exists $ModuleByPat{$file};
184 # If still unresolved files...
185 if (my @ToDo = grep { !defined $ModuleByFile{$_} } keys %ModuleByFile) {
187 # Cannot match what isn't there.
188 @ToDo = grep { -e $_ } @ToDo;
191 # Try prefix matching.
193 # Remove trailing slashes.
194 for (@ToDo) { s|/$|| }
199 for my $pat (keys %ModuleByPat) {
200 last unless keys %ToDo;
203 for my $file (keys %ToDo) {
204 if ($file =~ m|^$pat|i) {
205 $ModuleByFile{$file} = $ModuleByPat{$pat};
215 for my $file (@Files) {
216 if (defined $ModuleByFile{$file}) {
217 my $module = $ModuleByFile{$file};
218 my $maintainer = $Modules{$ModuleByFile{$file}}{MAINTAINER};
219 printf "%-15s $module $maintainer $Maintainers{$maintainer}\n", $file;
221 printf "%-15s ?\n", $file;
226 duplicated_maintainers();
233 sub duplicated_maintainers {
235 for my $k (keys %Modules) {
236 for my $f (get_module_files($k)) {
240 for my $f (keys %files) {
241 if ($files{$f} > 1) {
242 warn "File $f appears $files{$f} times in Maintainers.pl\n";