[Bps-public-commit] cpan2rt branch, master, updated. 172ac7869a52f914f1ff80e609a7c8dd2e469866

Dianne Skoll dianne at bestpractical.com
Fri Feb 26 09:48:51 EST 2021


The branch, master has been updated
       via  172ac7869a52f914f1ff80e609a7c8dd2e469866 (commit)
      from  fdf1d84d4d605d9bfc28bc6b1b844059cd2e99a9 (commit)

Summary of changes:
 lib/CPAN2RT.pm | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit 172ac7869a52f914f1ff80e609a7c8dd2e469866
Author: Dianne Skoll <dianne at bestpractical.com>
Date:   Fri Feb 26 09:48:17 2021 -0500

    Work around the fact that MetaCPAN::Client sometimes returns a string and sometimes an array of strings for a given field, with seemingly no way to predict what you will get.

diff --git a/lib/CPAN2RT.pm b/lib/CPAN2RT.pm
index eaa9ed3..e3017dc 100644
--- a/lib/CPAN2RT.pm
+++ b/lib/CPAN2RT.pm
@@ -334,19 +334,29 @@ sub _sync_bugtracker_cpan2rt {
 
         my $bugtracker = {};
 
-        # Record data
+        # MetaCPAN sometimes returns a string for each
+        # field, and sometimes an array.  Why?  We have no idea.
+        # But we have to handle it, so if we get back an array,
+        # pull out the first element... all the arrays I have seen
+        # so far have contained only one element.
         my $dist   = $data->{'distribution'};
+        $dist = $dist->[0] if ( (ref($dist) || '') eq 'ARRAY' );
         my $mailto = $data->{'resources.bugtracker.mailto'};
+        $mailto = $mailto->[0] if ( (ref($mailto) || '') eq 'ARRAY' );
         my $web    = $data->{'resources.bugtracker.web'};
+        $web = $web->[0] if ( (ref($web) || '') eq 'ARRAY' );
 
         if (!$dist) {
             #debug { "Result without distribution: " . Data::Dumper::Dumper($result) };
             next;
         }
 
-        next unless ($data->{'maturity'} || '') eq 'released';
-        next unless ($data->{'status'}   || '') eq 'latest';
-
+        my $maturity = $data->{'maturity'};
+        $maturity = $maturity->[0] if ( (ref($maturity) || '') eq 'ARRAY' );
+        my $status = $data->{'status'};
+        $status = $status->[0] if ( (ref($status) || '') eq 'ARRAY' );
+        next unless ($maturity || '') eq 'released';
+        next unless ($status   || '') eq 'latest';
 
         debug { "Got '$dist' ($mailto, $web)" };
 

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list