]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Common.pm
export the get source maintainers
[debbugs.git] / Debbugs / Common.pm
index 732ac2e5bf2f6c02fcaa4b718cb2a7780e3bfc2b..aad3fe6d18004f6d82649ffb6c97c271d202ff4c 100644 (file)
@@ -31,7 +31,7 @@ with equivalent (or better) functionality here.
 use warnings;
 use strict;
 use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT);
-use base qw(Exporter);
+use Exporter qw(import);
 
 BEGIN{
      $VERSION = 1.00;
@@ -40,6 +40,7 @@ BEGIN{
      @EXPORT = ();
      %EXPORT_TAGS = (util   => [qw(getbugcomponent getbuglocation getlocationpath get_hashname),
                                qw(appendfile overwritefile buglog getparsedaddrs getmaintainers),
+                                qw(getsourcemaintainers getsourcemaintainers_reverse),
                                qw(bug_status),
                                qw(getmaintainers_reverse),
                                qw(getpseudodesc),
@@ -299,6 +300,36 @@ sub getmaintainers_reverse{
      return $_maintainer_rev;
 }
 
+=head2 getsourcemaintainers
+
+     my $maintainer = getsourcemaintainers()->{debbugs}
+
+Returns a hashref of src_package => maintainer pairs.
+
+=cut
+
+our $_source_maintainer = undef;
+our $_source_maintainer_rev = undef;
+sub getsourcemaintainers {
+    return $_source_maintainer if defined $_source_maintainer;
+    package_maintainer(rehash => 1);
+    return $_source_maintainer;
+}
+
+=head2 getsourcemaintainers_reverse
+
+     my @src_packages = @{getsourcemaintainers_reverse->{'don@debian.org'}||[]};
+
+Returns a hashref of maintainer => [qw(list of source packages)] pairs.
+
+=cut
+
+sub getsourcemaintainers_reverse{
+     return $_source_maintainer_rev if defined $_source_maintainer_rev;
+     package_maintainer(rehash => 1);
+     return $_source_maintainer_rev;
+}
+
 =head2 package_maintainer
 
      my @s = package_maintainer(source => [qw(foo bar baz)],
@@ -324,8 +355,6 @@ files; defaults to 0
 
 =cut
 
-our $_source_maintainer = undef;
-our $_source_maintainer_rev = undef;
 sub package_maintainer {
     my %param = validate_with(params => \@_,
                              spec   => {source => {type => SCALAR|ARRAYREF,
@@ -435,8 +464,8 @@ sub __add_to_hash {
     binmode($fh,':encoding(UTF-8)');
     while (<$fh>) {
        chomp;
-       next unless m/^(\S+)\s+(\S.*\S)\s*$/;
-       my ($key,$value)=($1,$2);
+        next unless m/^(\S+)\s+(\S.*\S)\s*$/;
+        my ($key,$value)=($1,$2);
        $key = lc $key;
        $forward->{$key}= $value;
        if (defined $reverse) {
@@ -937,7 +966,7 @@ sub cleanup_eval_fail {
     # ditch the "at foo/bar/baz.pm line 5"
     $error =~ s/\sat\s\S+\sline\s\d+//;
     # ditch croak messages
-    $error =~ s/^\t+.+\n?//g;
+    $error =~ s/^\t+.+\n?//mg;
     # ditch trailing multiple periods in case there was a cascade of
     # die messages.
     $error =~ s/\.+$/\./;