X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Porting%2FMaintainers.pm;h=0b03e0579e50801800be577b201cd0ee556ad8d1;hb=12fc04c96e084fc3d1f066acd95f1b212e9bc1e3;hp=3cf48560c6a4f85189b68f96176e4a99f3e423ef;hpb=0cf5154416a0eea5954731af354063d20292b41e;p=p5sagit%2Fp5-mst-13.2.git diff --git a/Porting/Maintainers.pm b/Porting/Maintainers.pm index 3cf4856..0b03e05 100644 --- a/Porting/Maintainers.pm +++ b/Porting/Maintainers.pm @@ -7,15 +7,19 @@ package Maintainers; use strict; use lib "Porting"; +# Please don't use post 5.008 features as this module is used by +# Porting/makemeta, and that in turn has to be run by the perl just built. +use 5.008; require "Maintainers.pl"; use vars qw(%Modules %Maintainers); -use vars qw(@ISA @EXPORT_OK); +use vars qw(@ISA @EXPORT_OK $VERSION); @ISA = qw(Exporter); @EXPORT_OK = qw(%Modules %Maintainers get_module_files get_module_pat show_results process_options); +$VERSION = 0.02; require Exporter; use File::Find; @@ -67,10 +71,15 @@ sub get_maintainer_modules { sub usage { print <<__EOF__; -$0: Usage: $0 [[--maintainer M --module M --files]|file ...] +$0: Usage: $0 [[--maintainer M --module M --files]|[--check] [commit] | [file ...] --maintainer M list all maintainers matching M --module M list all modules matching M --files list all files +--check check consistency of Maintainers.pl + with a file checks if it has a maintainer + with a dir checks all files have a maintainer + otherwise checks for multiple maintainers +--opened list all modules of modified files Matching is case-ignoring regexp, author matching is both by the short id and by the full name and email. A "module" may not be just a module, it may be a file or files or a subdirectory. @@ -82,6 +91,8 @@ __EOF__ my $Maintainer; my $Module; my $Files; +my $Check; +my $Opened; sub process_options { usage() @@ -90,9 +101,23 @@ sub process_options { 'maintainer=s' => \$Maintainer, 'module=s' => \$Module, 'files' => \$Files, + 'check' => \$Check, + 'opened' => \$Opened, ); - my @Files = @ARGV; + my @Files; + + if ($Opened) { + chomp (@Files = `git ls-files -m --full-name`); + die if $?; + } elsif (@ARGV == 1 && + $ARGV[0] =~ /^(?:HEAD|[0-9a-f]{4,40})(?:~\d+)?\^*$/) { + my $command = "git diff --name-only $ARGV[0]^ $ARGV[0]"; + chomp (@Files = `$command`); + die "'$command' failed: $?" if $?; + } else { + @Files = @ARGV; + } usage() if @Files && ($Maintainer || $Module || $Files); @@ -142,10 +167,17 @@ sub show_results { my @files = get_module_files($m); printf "%-15s @files\n", $m; } else { - printf "%-15s $Modules{$m}{MAINTAINER}\n", $m; + printf "%-15s %-12s %s\n", $m, $Modules{$m}{MAINTAINER}, $Modules{$m}{UPSTREAM}||'unknown'; } } } + } elsif ($Check) { + if( @Files ) { + missing_maintainers( qr{\.(?:[chty]|p[lm]|xs)\z}msx, @Files) + } + else { + duplicated_maintainers(); + } } elsif (@Files) { my %ModuleByFile; @@ -213,16 +245,56 @@ sub show_results { if (defined $ModuleByFile{$file}) { my $module = $ModuleByFile{$file}; my $maintainer = $Modules{$ModuleByFile{$file}}{MAINTAINER}; - printf "%-15s $module $maintainer $Maintainers{$maintainer}\n", $file; + my $upstream = $Modules{$module}{UPSTREAM}||'unknown'; + printf "%-15s [%-7s] $module $maintainer $Maintainers{$maintainer}\n", $file, $upstream; } else { printf "%-15s ?\n", $file; } } } + elsif ($Opened) { + print STDERR "(No files are modified)\n"; + } else { usage(); } } +my %files; + +sub maintainers_files { + %files = (); + for my $k (keys %Modules) { + for my $f (get_module_files($k)) { + ++$files{$f}; + } + } +} + +sub duplicated_maintainers { + maintainers_files(); + for my $f (keys %files) { + if ($files{$f} > 1) { + warn "File $f appears $files{$f} times in Maintainers.pl\n"; + } + } +} + +sub warn_maintainer { + my $name = shift; + warn "File $name has no maintainer\n" if not $files{$name}; +} + +sub missing_maintainers { + my($check, @path) = @_; + maintainers_files(); + my @dir; + for my $d (@path) { + if( -d $d ) { push @dir, $d } else { warn_maintainer($d) } + } + find sub { warn_maintainer($File::Find::name) if /$check/; }, @dir + if @dir; +} + 1;