X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FCGI%2FPkgreport.pm;h=28c1f75b4d6a63fbc7ff7dcac3ed5ef45daa037b;hb=f4cac5c0b345b08f67844df7eecd18f66c156c9e;hp=51ebe42266119cdb0cc5ae9dfb8c4bb133319ed5;hpb=46fa42780ecb746d7bec2fb01190b05584b9283e;p=debbugs.git diff --git a/Debbugs/CGI/Pkgreport.pm b/Debbugs/CGI/Pkgreport.pm index 51ebe42..28c1f75 100644 --- a/Debbugs/CGI/Pkgreport.pm +++ b/Debbugs/CGI/Pkgreport.pm @@ -28,11 +28,16 @@ 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); +use Debbugs::Collection::Bug; + +use Carp; +use List::AllUtils qw(apply); + use Debbugs::Config qw(:config :globals); use Debbugs::CGI qw(:url :html :util); use Debbugs::Common qw(:misc :util :date); @@ -41,6 +46,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); @@ -51,13 +57,9 @@ BEGIN{ @EXPORT = (); %EXPORT_TAGS = (html => [qw(short_bug_status_html pkg_htmlizebugs), - qw(pkg_javascript), - qw(pkg_htmlselectyesno pkg_htmlselectsuite), - qw(buglinklist pkg_htmlselectarch) ], - misc => [qw(generate_package_info make_order_list), - qw(myurl), - qw(get_bug_order_index determine_ordering), + misc => [qw(generate_package_info), + qw(determine_ordering), ], ); @EXPORT_OK = (qw()); @@ -78,12 +80,15 @@ sub generate_package_info{ spec => {binary => {type => BOOLEAN, default => 1, }, - package => {type => SCALAR|ARRAYREF, + package => {type => SCALAR,#|ARRAYREF, }, options => {type => HASHREF, }, bugs => {type => ARRAYREF, }, + schema => {type => OBJECT, + optional => 1, + }, }, ); @@ -94,25 +99,41 @@ 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, + hash_slice(%param,qw(schema)), + ); + 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 { - print {$output} "

No maintainer for $showpkg. Please do not report new bugs against this package.

\n"; - } - my @pkgs = getsrcpkgs($srcforpkg); + print {$output} "

There is no maintainer for $showpkg. ". + "This means that this package no longer exists (or never existed). ". + "Please do not report new bugs against this package.

\n"; + } + my @pkgs = source_to_binary(source => $srcforpkg, + hash_slice(%param,qw(schema)), + binary_only => 1, + # if there are distributions, only bother to + # show packages which are currently in a + # distribution. + @{$config{distributions}//[]} ? + (dist => [@{$config{distributions}}]) : (), + ); @pkgs = grep( !/^\Q$package\E$/, @pkgs ); if ( @pkgs ) { @pkgs = sort @pkgs; @@ -129,17 +150,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"; } else { - if ($package and defined $gPackagePages) { + if ($package and defined $config{package_pages} and length $config{package_pages}) { push @references, sprintf "to the %s package page", - html_escape("http://${gPackagePages}/$package"), html_escape("$package"); + html_escape("$config{package_pages}/$package"), html_escape("$package"); } - if (defined $gSubscriptionDomain) { + if (defined $config{package_tracking_domain} and + length $config{package_tracking_domain}) { my $ptslink = $param{binary} ? $srcforpkg : $package; - push @references, q(to the Package Tracking System); + # the pts only wants the source, and doesn't care about src: (#566089) + $ptslink =~ s/^src://; + push @references, q(to the Package Tracking System); } # Only output this if the source listing is non-trivial. if ($param{binary} and $srcforpkg) { @@ -154,17 +178,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 $param{maint} || defined $param{maintenc}) { + if (@maint) { print {$output} "

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

\n", - html_escape("http://${debbugs::gWebDomain}/Reporting${debbugs::gHTMLSuffix}"); - } - if (not $maint and not @{$param{bugs}}) { - print {$output} "

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

"; + html_escape("$config{web_domain}/Reporting$config{html_suffix}"); } - return $output_scalar; + return decode_utf8($output_scalar); } @@ -196,49 +215,14 @@ display below sub short_bug_status_html { my %param = validate_with(params => \@_, - spec => {status => {type => HASHREF, - }, - options => {type => HASHREF, - default => {}, - }, - bug_options => {type => HASHREF, - default => {}, - }, - snippet => {type => SCALAR, - default => '', - }, + spec => {bug => {type => OBJECT, + isa => 'Debbugs::Bug', + }, }, ); - my %status = %{$param{status}}; - - $status{tags_array} = [sort(split(/\s+/, $status{tags}))]; - $status{date_text} = strftime('%a, %e %b %Y %T UTC', gmtime($status{date})); - $status{mergedwith_array} = [split(/ /,$status{mergedwith})]; - - my @blockedby= split(/ /, $status{blockedby}); - $status{blockedby_array} = []; - 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}; - push @{$status{blockedby_array}},{bug_num => $b, subject => $s{subject}, status => \%s}; - } - } - - my @blocks= split(/ /, $status{blocks}); - $status{blocks_array} = []; - if (@blocks && $status{"pending"} ne 'fixed' && ! length($status{done})) { - for my $b (@blocks) { - my %s = %{get_bug_status($b)}; - next if $s{"pending"} eq 'fixed' || length $s{done}; - push @{$status{blocks_array}}, {bug_num => $b, subject => $s{subject}, status => \%s}; - } - } - - return fill_in_template(template => 'cgi/short_bug_status', - variables => {status => \%status, + variables => {bug => $param{bug}, isstrongseverity => \&Debbugs::Status::isstrongseverity, html_escape => \&Debbugs::CGI::html_escape, looks_like_number => \&Scalar::Util::looks_like_number, @@ -248,127 +232,15 @@ sub short_bug_status_html { '&version_url' => \&Debbugs::CGI::version_url, '&secs_to_english' => \&Debbugs::Common::secs_to_english, '&strftime' => \&POSIX::strftime, + '&maybelink' => \&Debbugs::CGI::maybelink, }, ); - - my $result = ""; - - my $showseverity; - if ($status{severity} eq 'normal') { - $showseverity = ''; - } - elsif (isstrongseverity($status{severity})) { - $showseverity = "Severity: $status{severity};\n"; - } - else { - $showseverity = "Severity: $status{severity};\n"; - } - - $result .= package_links(package => $status{package}, - options => $param{options}, - ); - - my $showversions = ''; - if (@{$status{found_versions}}) { - my @found = @{$status{found_versions}}; - $showversions .= join ', ', map {s{/}{ }; html_escape($_)} @found; - } - if (@{$status{fixed_versions}}) { - $showversions .= '; ' if length $showversions; - $showversions .= 'fixed: '; - my @fixed = @{$status{fixed_versions}}; - $showversions .= join ', ', map {s{/}{ }; html_escape($_)} @fixed; - } - $result .= ' ($showversions)} if length $showversions; - $result .= ";\n"; - - $result .= $showseverity; - $result .= "Reported by: ".package_links(submitter=>$status{originator}, - class => "submitter", - ); - $result .= ";\nOwned by: " . package_links(owner => $status{owner}, - class => "submitter", - ) - if length $status{owner}; - $result .= ";\nTags: " - . html_escape(join(", ", sort(split(/\s+/, $status{tags})))) - . "" - if (length($status{tags})); - - $result .= (length($status{mergedwith})?";\nMerged with ":"") . - bug_links(bug => [split(/ /,$status{mergedwith})], - class => "submitter", - ); - $result .= (length($status{blockedby})?";\nBlocked by ":"") . - bug_links(bug => [split(/ /,$status{blockedby})], - class => "submitter", - ); - $result .= (length($status{blocks})?";\nBlocks ":"") . - bug_links(bug => [split(/ /,$status{blocks})], - class => "submitter", - ); - - if (length($status{done})) { - $result .= "
Done: " . html_escape($status{done}); - my $days = bug_archiveable(bug => $status{id}, - status => \%status, - days_until => 1, - ); - if ($days >= 0 and defined $status{location} and $status{location} ne 'archive') { - $result .= ";\nCan be archived" . ( $days == 0 ? " today" : $days == 1 ? " in $days day" : " in $days days" ) . ""; - } - elsif (defined $status{location} and $status{location} eq 'archived') { - $result .= ";\nArchived."; - } - } - - unless (length($status{done})) { - if (length($status{forwarded})) { - $result .= ";\nForwarded to " - . join(', ', - map {maybelink($_)} - split /\,\s+/,$status{forwarded} - ); - } - # Check the age of the logfile - my ($days_last,$eng_last) = secs_to_english(time - $status{log_modified}); - my ($days,$eng) = secs_to_english(time - $status{date}); - - if ($days >= 7) { - my $font = ""; - my $efont = ""; - $font = "em" if ($days > 30); - $font = "strong" if ($days > 60); - $efont = "" if ($font); - $font = "<$font>" if ($font); - - $result .= ";\n ${font}$eng old$efont"; - } - if ($days_last > 7) { - my $font = ""; - my $efont = ""; - $font = "em" if ($days_last > 30); - $font = "strong" if ($days_last > 60); - $efont = "" if ($font); - $font = "<$font>" if ($font); - - $result .= ";\n ${font}Modified $eng_last ago$efont"; - } - } - - $result .= "."; - - return $result; } sub pkg_htmlizebugs { my %param = validate_with(params => \@_, - spec => {bugs => {type => ARRAYREF, + spec => {bugs => {type => OBJECT, }, names => {type => ARRAYREF, }, @@ -403,27 +275,23 @@ sub pkg_htmlizebugs { options => {type => HASHREF, default => {}, }, + dist => {type => SCALAR, + optional => 1, + }, + schema => {type => OBJECT, + optional => 1, + }, } ); - my @bugs = @{$param{bugs}}; - - my @status = (); + my $bugs = $param{bugs}; my %count; my $header = ''; my $footer = "

Summary

\n"; - my @dummy = ($gRemoveAge); #, @gSeverityList, @gSeverityDisplay); #, $gHTMLExpireNote); - - if (@bugs == 0) { + if ($bugs->count == 0) { return "

No reports found!

\n"; } - if ( $param{bug_rev} ) { - @bugs = sort {$b<=>$a} @bugs; - } - else { - @bugs = sort {$a<=>$b} @bugs; - } my %seenmerged; my %common = ( @@ -454,50 +322,50 @@ 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 $sorter = sub {$_[0]->id <=> $_[1]->id}; + if ($param{bug_rev}) { + $sorter = sub {$_[1]->id <=> $_[0]->id} } - if ($param{bug_order} eq 'age') { - # MWHAHAHAHA - @status = sort {$a->[1]{log_modified} <=> $b->[1]{log_modified}} @status; + elsif ($param{bug_order} eq 'age') { + $sorter = sub {$_[0]->modified->epoch <=> $_[1]->modified->epoch}; } elsif ($param{bug_order} eq 'agerev') { - @status = sort {$b->[1]{log_modified} <=> $a->[1]{log_modified}} @status; - } + $sorter = sub {$_[1]->modified->epoch <=> $_[0]->modified->epoch}; + } + my @status; + for my $bug ($bugs->sort($sorter)) { + next if + $bug->filter(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(bug => $bug, + ) . "\n"; + push @status, [ $bug, $html ]; + } + # parse bug order indexes into subroutines + my @order_subs = + map { + my $a = $_; + [map {parse_order_statement_to_subroutine($_)} @{$a}]; + } @{$param{prior}}; for my $entry (@status) { my $key = ""; - for my $i (0..$#{$param{prior}}) { - my $v = get_bug_order_index($param{prior}[$i], $entry->[1]); + for my $i (0..$#order_subs) { + my $v = get_bug_order_index($order_subs[$i], $entry->[0]); $count{"g_${i}_${v}"}++; $key .= "_$v"; } - $section{$key} .= $entry->[2]; + $section{$key} .= $entry->[1]; $count{"_$key"}++; } my $result = ""; if ($param{ordering} eq "raw") { - $result .= "\n"; + $result .= "\n"; } else { $header .= "
    \n