X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FCGI%2FPkgreport.pm;h=01e661f30d987fff3cee189cab1803e6c1a4607d;hb=e09c4d3c9adb00e42d9af5daf9b1d5dd04264e6b;hp=e87125c0ca4b247f5c37a73de2cea0df722cc53f;hpb=d03d7cc5c01e63b3f8e64cc4d13a581a436fe23a;p=debbugs.git diff --git a/Debbugs/CGI/Pkgreport.pm b/Debbugs/CGI/Pkgreport.pm index e87125c..01e661f 100644 --- a/Debbugs/CGI/Pkgreport.pm +++ b/Debbugs/CGI/Pkgreport.pm @@ -28,7 +28,7 @@ None known. use warnings; use strict; use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT); -use base qw(Exporter); +use Exporter qw(import); use IO::Scalar; use Params::Validate qw(validate_with :types); @@ -41,6 +41,7 @@ use Debbugs::Bugs qw(bug_filter); use Debbugs::Packages qw(:mapping); use Debbugs::Text qw(:templates); +use Encode qw(decode_utf8); use POSIX qw(strftime); @@ -80,6 +81,9 @@ sub generate_package_info{ }, bugs => {type => ARRAYREF, }, + schema => {type => OBJECT, + optional => 1, + }, }, ); @@ -90,19 +94,24 @@ sub generate_package_info{ my %pkgsrc = %{getpkgsrc()}; my $srcforpkg = $package; - if ($param{binary} and exists $pkgsrc{$package} - and defined $pkgsrc{$package}) { - $srcforpkg = $pkgsrc{$package}; + if ($param{binary}) { + $srcforpkg = + binary_to_source(source_only => 1, + scalar_only => 1, + binary => $package, + hash_slice(%param,qw(schema)), + ); } my $showpkg = html_escape($package); - my $maintainers = getmaintainers(); - my $maint = $maintainers->{$srcforpkg}; - if (defined $maint) { + my @maint = package_maintainer($param{binary}?'binary':'source', + $package + ); + if (@maint) { print {$output} '

'; - print {$output} (($maint =~ /,/)? "Maintainer for $showpkg is " + print {$output} (@maint > 1? "Maintainer for $showpkg is " : "Maintainers for $showpkg are ") . - package_links(maint => $maint); + package_links(maintainer => \@maint); print {$output} ".

\n"; } else { @@ -127,27 +136,20 @@ sub generate_package_info{ my @references; my $pseudodesc = getpseudodesc(); if ($package and defined($pseudodesc) and exists($pseudodesc->{$package})) { - push @references, "to the ". + push @references, "to the ". "list of other pseudo-packages"; } - elsif (not defined $maint and not @{$param{bugs}}) { - # don't bother printing out this information, because it's - # already present above. - # print {$output} "

There is no record of the " . html_escape($package) . - # ($param{binary} ? " package" : " source package") . - # ", and no bugs have been filed against it.

"; - } else { if ($package and defined $config{package_pages} and length $config{package_pages}) { push @references, sprintf "to the %s package page", - html_escape("http://$config{package_pages}/$package"), html_escape("$package"); + html_escape("$config{package_pages}/$package"), html_escape("$package"); } - if (defined $config{subscription_domain} and - length $config{subscription_domain}) { + if (defined $config{package_tracking_domain} and + length $config{package_tracking_domain}) { my $ptslink = $param{binary} ? $srcforpkg : $package; # the pts only wants the source, and doesn't care about src: (#566089) $ptslink =~ s/^src://; - push @references, q(to the Package Tracking System); + push @references, q(to the Package Tracking System); } # Only output this if the source listing is non-trivial. if ($param{binary} and $srcforpkg) { @@ -162,12 +164,12 @@ sub generate_package_info{ $references[$#references] = "or $references[$#references]" if @references > 1; print {$output} "

You might like to refer ", join(", ", @references), ".

\n"; } - if (defined $maint) { + if (@maint) { print {$output} "

If you find a bug not listed here, please\n"; printf {$output} "report it.

\n", - html_escape("http://$config{web_domain}/Reporting$config{html_suffix}"); + html_escape("$config{web_domain}/Reporting$config{html_suffix}"); } - return $output_scalar; + return decode_utf8($output_scalar); } @@ -224,7 +226,7 @@ sub short_bug_status_html { if (@blockedby && $status{"pending"} ne 'fixed' && ! length($status{done})) { for my $b (@blockedby) { my %s = %{get_bug_status($b)}; - next if $s{"pending"} eq 'fixed' || length $s{done}; + next if (defined $s{pending} and $s{pending} eq 'fixed') or (defined $s{done} and length $s{done}); push @{$status{blockedby_array}},{bug_num => $b, subject => $s{subject}, status => \%s}; } } @@ -300,6 +302,9 @@ sub pkg_htmlizebugs { dist => {type => SCALAR, optional => 1, }, + schema => {type => OBJECT, + optional => 1, + }, } ); my @bugs = @{$param{bugs}}; @@ -349,28 +354,30 @@ sub pkg_htmlizebugs { push @{$exclude{$key}}, split /\s*,\s*/, $value; } - foreach my $bug (@bugs) { - my %status = %{get_bug_status(bug=>$bug, - (exists $param{dist}?(dist => $param{dist}):()), - bugusertags => $param{bugusertags}, - (exists $param{version}?(version => $param{version}):()), - (exists $param{arch}?(arch => $param{arch}):(arch => $config{default_architectures})), - )}; - next unless %status; - next if bug_filter(bug => $bug, - status => \%status, - repeat_merged => $param{repeatmerged}, - seen_merged => \%seenmerged, - (keys %include ? (include => \%include):()), - (keys %exclude ? (exclude => \%exclude):()), - ); - - my $html = "
  • "; ##%d: %s\n
    ", - #bug_url($bug), $bug, html_escape($status{subject}); - $html .= short_bug_status_html(status => \%status, - options => $param{options}, - ) . "\n"; - push @status, [ $bug, \%status, $html ]; + my $binary_to_source_cache = {}; + my $statuses = + get_bug_statuses(bug => \@bugs, + hash_slice(%param, + qw(dist version schema bugusertags), + ), + (exists $param{arch}?(arch => $param{arch}):(arch => $config{default_architectures})), + binary_to_source_cache => $binary_to_source_cache, + ); + for my $bug (sort {$a <=> $b} keys %{$statuses}) { + next unless %{$statuses->{$bug}}; + next if bug_filter(bug => $bug, + status => $statuses->{$bug}, + repeat_merged => $param{repeatmerged}, + seen_merged => \%seenmerged, + (keys %include ? (include => \%include):()), + (keys %exclude ? (exclude => \%exclude):()), + ); + + my $html = "
  • "; ##%d: %s\n
    ", + $html .= short_bug_status_html(status => $statuses->{$bug}, + options => $param{options}, + ) . "\n"; + push @status, [ $bug, $statuses->{$bug}, $html ]; } if ($param{bug_order} eq 'age') { # MWHAHAHAHA @@ -458,35 +465,57 @@ sub pkg_htmlizebugs { return $result; } +sub parse_order_statement_into_boolean { + my ($statement,$status,$tags) = @_; + + if (not defined $tags) { + $tags = {map { $_, 1 } split / /, $status->{"tags"} + } + if defined $status->{"tags"}; + + } + # replace all + with && + $statement =~ s/\+/&&/g; + # replace all , with || + $statement =~ s/,/||/g; + $statement =~ s{([^\&\|\=]+) # field + = + ([^\&\|\=]+) # value + }{ + my $ok = 0; + if ($1 eq 'tag') { + $ok = 1 if defined $tags->{$2}; + } else { + $ok = 1 if defined $status->{$1} and + $status->{$1} eq $2; + } + $ok; + }exg; + # check that the parsed statement is just valid boolean statements + if ($statement =~ /^([01\(\)\&\|]+)$/) { + return eval "$1"; + } else { + # this is an invalid boolean statement + return 0; + } +} + sub get_bug_order_index { my $order = shift; my $status = shift; - my $pos = -1; - - my %tags = (); - %tags = map { $_, 1 } split / /, $status->{"tags"} - if defined $status->{"tags"}; - + my $pos = 0; + my $tags = {map { $_, 1 } split / /, $status->{"tags"} + } + if defined $status->{"tags"}; for my $el (@${order}) { - $pos++; - my $match = 1; - for my $item (split /[+]/, $el) { - my ($f, $v) = split /=/, $item, 2; - next unless (defined $f and defined $v); - my $isokay = 0; - $isokay = 1 if (defined $status->{$f} and $v eq $status->{$f}); - $isokay = 1 if ($f eq "tag" && defined $tags{$v}); - unless ($isokay) { - $match = 0; - last; - } - } - if ($match) { - return $pos; - last; - } + if (not length $el or + parse_order_statement_into_boolean($el,$status,$tags) + ) { + return $pos; + } + $pos++; } - return $pos + 1; + return $pos; } # sets: my @names; my @prior; my @title; my @order;