split ' ', $Modules{$m}{FILES};
}
+# exand dir/ or foo* into a full list of files
+#
+sub expand_glob {
+ sort { lc $a cmp lc $b }
+ map {
+ -f $_ ? # File as-is.
+ $_ :
+ -d _ ? # Recurse into directories.
+ do {
+ my @files;
+ find(
+ sub {
+ push @files, $File::Find::name
+ if -f $_ && exists $MANIFEST{$File::Find::name};
+ }, $_);
+ @files;
+ }
+ # The rest are globbable patterns; expand the glob, then
+ # recurively perform directory expansion on any results
+ : expand_glob(grep -e $_,glob($_))
+ } @_;
+}
+
sub get_module_files {
my $m = shift;
- sort { lc $a cmp lc $b }
- map {
- -f $_ ? # Files as-is.
- $_ :
- -d _ ? # Recurse into directories.
- do {
- my @files;
- find(
- sub {
- push @files, $File::Find::name
- if -f $_ && exists $MANIFEST{$File::Find::name};
- }, $_);
- @files;
- }
- : glob($_) # The rest are globbable patterns.
- } get_module_pat($m);
+ my %exclude;
+ my @files;
+ for (get_module_pat($m)) {
+ if (s/^!//) {
+ $exclude{$_}=1 for expand_glob($_);
+ }
+ else {
+ push @files, expand_glob($_);
+ }
+ }
+ return grep !$exclude{$_}, @files;
}
+
sub get_maintainer_modules {
my $m = shift;
sort { lc $a cmp lc $b }
}
sub usage {
- print <<__EOF__;
-$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
+ warn <<__EOF__;
+$0: Usage:
+ --maintainer M | --module M [--files]
+ List modules or maintainers matching the pattern M.
+ With --files, list all the files associated with them
+or
+ --check | --checkmani [commit | file ... | dir ... ]
+ 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
+ with a commit checks files modified by that commit
+ no arg checks for multiple maintainers
+ --checkmani is like --check, but only reports on unclaimed
+ files if they are in MANIFEST
+or
+ --opened | file ....
+ List the module ownership of modified or the listed 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.
my $Module;
my $Files;
my $Check;
+my $Checkmani;
my $Opened;
sub process_options {
'module=s' => \$Module,
'files' => \$Files,
'check' => \$Check,
+ 'checkmani' => \$Checkmani,
'opened' => \$Opened,
);
my @Files;
if ($Opened) {
+ usage if @ARGV;
chomp (@Files = `git ls-files -m --full-name`);
die if $?;
} elsif (@ARGV == 1 &&
}
}
}
- } elsif ($Check) {
+ } elsif ($Check or $Checkmani) {
if( @Files ) {
- missing_maintainers( qr{\.(?:[chty]|p[lm]|xs)\z}msx, @Files)
+ missing_maintainers(
+ $Checkmani
+ ? sub { -f $_ and exists $MANIFEST{$File::Find::name} }
+ : sub { /\.(?:[chty]|p[lm]|xs)\z/msx },
+ @Files
+ );
}
else {
duplicated_maintainers();
for my $d (@path) {
if( -d $d ) { push @dir, $d } else { warn_maintainer($d) }
}
- find sub { warn_maintainer($File::Find::name) if /$check/; }, @dir
+ find sub { warn_maintainer($File::Find::name) if $check->() }, @dir
if @dir;
}