]> xenbits.xensource.com Git - people/aperard/emesinae.git/commitdiff
make tidy
authorIan Campbell <ian.campbell@citrix.com>
Mon, 1 Jul 2013 10:37:04 +0000 (11:37 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 1 Jul 2013 10:46:11 +0000 (11:46 +0100)
CGI/bug.pl
CGI/bugs.pl
CGI/common.pl
CGI/message.pl
Emesinae/Bug.pm
Emesinae/Common.pm
Emesinae/Message.pm
config/emesinae.conf
scripts/control.pl
scripts/receive.pl

index feffd49682d5ef084d3507672030d296b41c56f0..3c66bd30dd756e69ba4f186f0cefad554ccb84cd 100755 (executable)
@@ -7,8 +7,8 @@ use POSIX qw/strftime/;
 
 use CGI qw/:standard/;
 use CGI::Carp qw(fatalsToBrowser);
-$CGI::POST_MAX=1024 * 100; # max 100K posts
-$CGI::DISABLE_UPLOADS = 1; # no uploads
+$CGI::POST_MAX        = 1024 * 100;    # max 100K posts
+$CGI::DISABLE_UPLOADS = 1;             # no uploads
 
 use URI::Escape;
 
@@ -25,36 +25,40 @@ require 'common.cgi';
 readconfig;
 my $dbh = opendb;
 
-sub fourohfour()
-{
+sub fourohfour() {
     my $id = shift;
-    print header( -charset => 'utf-8', -status => '404 Not Found');
+    print header( -charset => 'utf-8', -status => '404 Not Found' );
     print start_html(
         -title => $c{TrackerName} . ": 404 - Not found",
         -style => { 'src' => $c{StyleSheet} }
     );
 
     print h1("404 - Not Found");
-    print p([ "No Bugs Here...", "Cannot find bug at: " .code(htmlsanit(url(-absolute=>1)))]);
+    print p(
+        [
+            "No Bugs Here...",
+            "Cannot find bug at: " . code( htmlsanit( url( -absolute => 1 ) ) )
+        ]
+    );
     print end_html;
     exit(0);
 }
 
 # Parse path to determine bug number and (optional) mode:
 
-my $path = url(-absolute=>1);
+my $path = url( -absolute => 1 );
 
 $path =~ m,^$c{CGIPath}bug/([0-9]+)(?:/(mbox))?/?$, or fourohfour();
 
 my $bugid = $1;
-my $mode = "normal";
+my $mode  = "normal";
 $mode = $2 if $2;
 
 my $bug = Emesinae::Bug->new( $dbh, ID => $bugid );
 fourohfour() unless $bug;
 
 if ( $mode eq "mbox" ) {
-    print header( -type => 'application/mbox', -charset => 'utf-8',);
+    print header( -type => 'application/mbox', -charset => 'utf-8', );
 
     foreach my $m ( sort msgcmp $bug->messages ) {
         eval {
@@ -70,6 +74,7 @@ if ( $mode eq "mbox" ) {
             $fh = $m->body;
             print for (<$fh>);
         };
+
         # Ignore errors...
     }
 
@@ -99,18 +104,15 @@ print div(
             "Date: " . htmlsanit($creationdate),
             "Last Update: " . htmlsanit($lastchangedate),
             "Severity: " . htmlsanit( $bug->{severity} ),
-            "Affects: " . htmlsanit(join(", ", $bug->tags("affects") ) ),
+            "Affects: " . htmlsanit( join( ", ", $bug->tags("affects") ) ),
             "State: " . b( $bug->{open} ? "Open" : "Closed" )
         ]
     )
 );
 
-print p(
-       { -class => "bugcontrol" },
-       "[ "
-         . buglink($bug, "Retrieve as mbox", "/mbox")
-         . " ]"
-   ) . "\n";
+print p( { -class => "bugcontrol" },
+    "[ " . buglink( $bug, "Retrieve as mbox", "/mbox" ) . " ]" )
+  . "\n";
 
 print hr;
 
index 158e5617627927bda68bc67e338f0a211ce5e5dc..aa642465c07e3beb67d1fb048523ea78191982cf 100755 (executable)
@@ -5,8 +5,8 @@ use warnings;
 
 use CGI qw/:standard/;
 use CGI::Carp qw(fatalsToBrowser);
-$CGI::POST_MAX=1024 * 100; # max 100K posts
-$CGI::DISABLE_UPLOADS = 1; # no uploads
+$CGI::POST_MAX        = 1024 * 100;    # max 100K posts
+$CGI::DISABLE_UPLOADS = 1;             # no uploads
 
 use Emesinae::Bug;
 use Emesinae::Common;
@@ -79,16 +79,16 @@ $(document).ready(function() {
 EOS
 
 print start_html(
-    -title => $c{TrackerName} . ": $ml - All Bugs",
-    -style => { 'src' => $c{StyleSheet} },
+    -title  => $c{TrackerName} . ": $ml - All Bugs",
+    -style  => { 'src' => $c{StyleSheet} },
     -script => [
-                { -type => 'text/javascript',
-                  -src  => '/javascript/jquery/jquery.js',
-                },
-                { -code => $jscript,
-                },
-               ]
-        
+        {
+            -type => 'text/javascript',
+            -src  => '/javascript/jquery/jquery.js',
+        },
+        { -code => $jscript, },
+      ]
+
 ) . "\n";
 
 print h1( $c{TrackerName} );
@@ -106,10 +106,21 @@ print p(
           . ". "
           . "Information on the control syntax is available "
           . a(
-            { -href => "http://" . $c{TrackerHost} . $c{StaticContent} . "control.txt" }, "here"
+            {
+                    -href => "http://"
+                  . $c{TrackerHost}
+                  . $c{StaticContent}
+                  . "control.txt"
+            },
+            "here"
           )
           . "."
-          . ($c{ControlHelpURL} ? " For guidance on manipulating bugs please see ".a( { -href => $c{ControlHelpURL} }, $c{ControlHelpURL})."." : "")
+          . (
+            $c{ControlHelpURL}
+            ? " For guidance on manipulating bugs please see "
+              . a( { -href => $c{ControlHelpURL} }, $c{ControlHelpURL} ) . "."
+            : ""
+          )
     ]
 ) . "\n";
 
@@ -125,11 +136,13 @@ foreach my $open ( 1, 0 ) {
 }
 
 if ( param('affectsfilter') ) {
-    print h2("Bugs affecting: " . join(", ",@{[param('affectsfilter')]}));
-} else {
+    print h2(
+        "Bugs affecting: " . join( ", ", @{ [ param('affectsfilter') ] } ) );
+}
+else {
     print h2("Bugs affecting: any version");
 }
-print p(ul (@index)) if @index;
+print p( ul(@index) ) if @index;
 
 if ( !$lists ) {
     $lists = h1("No bugs match the criteria.");
@@ -139,25 +152,26 @@ print hr(), "\n", $lists, hr(), "\n";
 print h2("Search");
 
 sub affects_checkboxes() {
-    my @affects = list_tags($dbh, "affects");
-    my (@values, @defaults, %attributes);
+    my @affects = list_tags( $dbh, "affects" );
+    my ( @values, @defaults, %attributes );
 
     foreach my $vers (@affects) {
         push @values, $vers->{name};
         push @defaults, $vers->{name} if $vers->{active} eq "true";
-        $attributes{$vers->{name}} = {};
+        $attributes{ $vers->{name} } = {};
 
-        $attributes{$vers->{name}}{'class'} = 'old_version' if $vers->{advanced} eq "true"
+        $attributes{ $vers->{name} }{'class'} = 'old_version'
+          if $vers->{advanced} eq "true";
     }
-    return checkbox_group(-name => 'affectsfilter',
-                          -values => \@values,
-                          -default => \@defaults,
-                          -attributes => \%attributes);
+    return checkbox_group(
+        -name       => 'affectsfilter',
+        -values     => \@values,
+        -default    => \@defaults,
+        -attributes => \%attributes
+    );
 }
 
-print
-  start_form( -method => "POST" ),
-  table(
+print start_form( -method => "POST" ), table(
     Tr(
         [
             td(
@@ -169,10 +183,21 @@ print
                     )
                 ]
             ),
-            td( [ "Title contains:", i("TBD") ] ), #textfield('titlefilter') ] ),
-            td( [ "Only Those Affecting:",
-                  affects_checkboxes(),
-                  small(a({-href=>"javascript:showOldVersions();", -id=>"showOldVersions"},"Show Older Versions"))
+            td( [ "Title contains:", i("TBD") ] )
+            ,    #textfield('titlefilter') ] ),
+            td(
+                [
+                    "Only Those Affecting:",
+                    affects_checkboxes(),
+                    small(
+                        a(
+                            {
+                                -href => "javascript:showOldVersions();",
+                                -id   => "showOldVersions"
+                            },
+                            "Show Older Versions"
+                        )
+                    )
                 ]
             ),
             td(
index 0698b20ce9a0690e2af5c33fac8037d299f6f86e..1ea05436e526b5e530e8f9abe10f29e6ed104a36 100644 (file)
@@ -4,9 +4,9 @@ sub cgipath {
 }
 
 sub buglink {
-    my $b   = shift;
-    my $t   = shift or $b->{title};
-    my $p   = shift or ""; # Optional subpath
+    my $b = shift;
+    my $t = shift or $b->{title};
+    my $p = shift or "";            # Optional subpath
 
     my $url = cgipath( "bug/" . $b->{id} . $p );
     return a( { href => $url }, $t );
index 2012b6bf880826f0ec13787cb2b483c52511927e..0877ceb49f1bbc6d45bed91c71fcb7148c6b7d5b 100755 (executable)
@@ -5,8 +5,8 @@ use warnings;
 
 use CGI qw/:standard/;
 use CGI::Carp qw(fatalsToBrowser);
-$CGI::POST_MAX=1024 * 100; # max 100K posts
-$CGI::DISABLE_UPLOADS = 1; # no uploads
+$CGI::POST_MAX        = 1024 * 100;    # max 100K posts
+$CGI::DISABLE_UPLOADS = 1;             # no uploads
 
 use Emesinae::Bug;
 use Emesinae::Common;
@@ -16,17 +16,22 @@ require 'common.cgi';
 readconfig;
 my $dbh = opendb;
 
-sub fourohfour()
-{
+sub fourohfour() {
     my $id = shift;
-    print header( -charset => 'utf-8', -status => '404 Not Found');
+    print header( -charset => 'utf-8', -status => '404 Not Found' );
     print start_html(
         -title => $c{TrackerName} . ": 404 - Not found",
         -style => { 'src' => $c{StyleSheet} }
     );
 
     print h1("404 - Not Found");
-    print p([ "No Message Here...", "Cannot find message at: " .code(htmlsanit(url(-absolute=>1)))]);
+    print p(
+        [
+            "No Message Here...",
+            "Cannot find message at: "
+              . code( htmlsanit( url( -absolute => 1 ) ) )
+        ]
+    );
     print end_html;
     exit(0);
 }
index 49e14cb52e1b02466b32fa5adac4a82729301f1d..4cf10cf2d579755b3194bcf565cf3442fce8216b 100644 (file)
@@ -6,7 +6,8 @@ use strict;
 use Emesinae::Message;
 use Emesinae::Common;
 
-my $SELECT_FIELDS = "bugs.bug_id,title_raw,creationdate,lastchangedate,owner_raw,severity,open";
+my $SELECT_FIELDS =
+  "bugs.bug_id,title_raw,creationdate,lastchangedate,owner_raw,severity,open";
 
 sub new {
     my $class = shift;
@@ -100,30 +101,30 @@ sub _set {
 }
 
 sub set_title {
-    my $self = shift;
+    my $self  = shift;
     my $title = shift;
 
-    $self->_set("title_raw", $title);
+    $self->_set( "title_raw", $title );
 }
 
 sub set_owner {
-    my $self = shift;
+    my $self  = shift;
     my $owner = shift;
 
-    $self->_set("owner_raw", $owner);
+    $self->_set( "owner_raw", $owner );
 }
 
 sub set_severity {
     my $self = shift;
-    my $sev = shift;
+    my $sev  = shift;
 
     assert_valid_severity($sev);
 
-    $self->_set("severity", $sev);
+    $self->_set( "severity", $sev );
 }
 
 sub _lookup_tag($$$) {
-    my ($self,$ns,$tag) = @_;
+    my ( $self, $ns, $tag ) = @_;
 
     my $sth = $self->{dbh}->prepare( "
         SELECT tag_id
@@ -131,7 +132,7 @@ sub _lookup_tag($$$) {
          WHERE namespace = ?
            AND name = ?
     " );
-    $sth->execute ( $ns, $tag ) or die "Unable to find tag $ns:$tag";
+    $sth->execute( $ns, $tag ) or die "Unable to find tag $ns:$tag";
     my $row = $sth->fetchrow_arrayref;
     $row or die "Unable to find tag $ns:$tag";
     $sth->finish;
@@ -140,37 +141,39 @@ sub _lookup_tag($$$) {
 }
 
 sub set_tag($$$) {
-    my ($self,$ns,$tag) = @_;
+    my ( $self, $ns, $tag ) = @_;
 
-    my $tag_id = $self->_lookup_tag($ns,$tag);
+    my $tag_id = $self->_lookup_tag( $ns, $tag );
 
     my $sth = $self->{dbh}->prepare( "
         INSERT OR REPLACE INTO bug2tag(bug_id,tag_id)
                   VALUES (?,?)
     " );
-    $sth->execute( $self->{id}, $tag_id ) or die "Setting tag $ns:$tag on Bug #" . $self->{id};
+    $sth->execute( $self->{id}, $tag_id )
+      or die "Setting tag $ns:$tag on Bug #" . $self->{id};
     $sth->rows == 1 or die "Failed to set tag $ns:$tag on Bug #" . $self->{id};
 
     $sth->finish;
 }
 
 sub clear_tag($$$) {
-    my ($self,$ns,$tag) = @_;
+    my ( $self, $ns, $tag ) = @_;
 
-    my $tag_id = $self->_lookup_tag($ns,$tag);
+    my $tag_id = $self->_lookup_tag( $ns, $tag );
 
     my $sth = $self->{dbh}->prepare( "
         DELETE FROM bug2tag
               WHERE bug_id = ?
                 AND tag_id = ?
     " );
-    $sth->execute( $self->{id}, $tag_id ) or die "Clearing tag $ns:$tag on Bug #" . $self->{id};
+    $sth->execute( $self->{id}, $tag_id )
+      or die "Clearing tag $ns:$tag on Bug #" . $self->{id};
 
     $sth->finish;
 }
 
 sub tags($$) {
-    my ($self,$ns) = @_;
+    my ( $self, $ns ) = @_;
 
     my $sth = $self->{dbh}->prepare( "
         SELECT tags.name
@@ -178,8 +181,9 @@ sub tags($$) {
          WHERE tags.tag_id == bug2tag.tag_id
            AND tags.namespace == ?
            AND bug2tag.bug_id == ?
-    ");
-    $sth->execute( $ns, $self->{id} ) or die "Listing $ns tags on Bug #" . $self->{id};
+    " );
+    $sth->execute( $ns, $self->{id} )
+      or die "Listing $ns tags on Bug #" . $self->{id};
 
     # An array ref (rows) of array refs (columns)
     my $tref = $sth->fetchall_arrayref();
@@ -275,28 +279,32 @@ sub listall ($$;%) {
     my $dbh   = shift;
     my %args  = @_;
 
-    my (@args,@where);
+    my ( @args, @where );
 
     my $select = "SELECT DISTINCT $SELECT_FIELDS FROM bugs";
 
     if    ( $args{State} eq "Open" )   { push @where, qq(open = "true" ) }
     elsif ( $args{State} eq "Closed" ) { push @where, qq(open = "false" ) }
 
-    if ( @{$args{Severities}} ) {
-        #print "<p>SEVERITIES: ".@{$args{Severities}}." ".join(" ",@{$args{Severities}})."</p>";
-        map { assert_valid_severity($_) } @ { $args{Severities} };
+    if ( @{ $args{Severities} } ) {
+
+#print "<p>SEVERITIES: ".@{$args{Severities}}." ".join(" ",@{$args{Severities}})."</p>";
+        map { assert_valid_severity($_) } @{ $args{Severities} };
         push @where,
-          join( " OR ", map { push @args,$_; qq{severity = ?} } @{ $args{Severities} } );
+          join( " OR ",
+            map { push @args, $_; qq{severity = ?} } @{ $args{Severities} } );
     }
 
-    if ( @{$args{Affects}} ) {
-        #print "<p>AFFECTS: ".@{$args{Affects}}." ".join(" ",@{$args{Affects}})."</p>";
+    if ( @{ $args{Affects} } ) {
+
+ #print "<p>AFFECTS: ".@{$args{Affects}}." ".join(" ",@{$args{Affects}})."</p>";
         $select .= " JOIN bug2tag ON bug2tag.bug_id == bugs.bug_id ";
         $select .= " JOIN tags ON bug2tag.tag_id == tags.tag_id ";
 
         push @where, "tags.namespace = \"affects\"";
         push @where,
-          join( " OR ", map { push @args,$_; qq{tags.name = ?} } @{ $args{Affects} });
+          join( " OR ",
+            map { push @args, $_; qq{tags.name = ?} } @{ $args{Affects} } );
     }
 
     $select .= " WHERE " . join( " AND ", map { qq{($_)} } @where ) if @where;
index 9763cb85c6f2d3cd5b0a01452069fa939d0d1c1e..d862bf72439a0aa8f77f9584243febb15d96a472 100644 (file)
@@ -36,11 +36,12 @@ sub readconfig () {
     $c{OwnerAddressFull}   = $c{OwnerAddress} . "@" . $c{MailDomain};
 
     if ( $c{ControlAllowPath} ) {
-        open CA, "<".$c{ControlAllowPath} or die "unable to open ".$c{ControlAllowPath}.": $!";
+        open CA, "<" . $c{ControlAllowPath}
+          or die "unable to open " . $c{ControlAllowPath} . ": $!";
         $c{ControAllow} = [];
         while (<CA>) {
             chomp;
-            push @ { $c{ControlAllow} }, $_;
+            push @{ $c{ControlAllow} }, $_;
         }
     }
 }
@@ -56,20 +57,20 @@ sub opendb () {
 }
 
 sub list_tags($$) {
-    my ($dbh,$ns) = @_;
+    my ( $dbh, $ns ) = @_;
 
     my $sth = $dbh->prepare( "
         SELECT name,active,advanced
           FROM tags
          WHERE namespace = ?
     " );
-    $sth->execute( $ns ) or die "Unable to obtain list of tags in namesapce $ns";
+    $sth->execute($ns) or die "Unable to obtain list of tags in namesapce $ns";
 
     # Gets an array ref of hash refs.
-    my $tags = $sth->fetchall_arrayref({});
+    my $tags = $sth->fetchall_arrayref( {} );
 
     $sth->finish;
-    return @{$tags}
+    return @{$tags};
 }
 
 #------- locking -------
index 38a29d8203f935351d64a8d5db1a586e70b9c9af..f445bb89fa0e900f7fdf1b74d4687319d04ebfd4 100644 (file)
@@ -169,8 +169,8 @@ sub update {
         my $refto =
           Emesinae::Message->lookup_msgid( $self->{dbh}, $irt, Insert => 1 );
         $sth =
-          $self->{dbh}
-          ->prepare(q{INSERT OR IGNORE INTO refs (parent_id,child_id) VALUES (?1,?2)});
+          $self->{dbh}->prepare(
+            q{INSERT OR IGNORE INTO refs (parent_id,child_id) VALUES (?1,?2)});
         $sth->execute( $refto->{id}, $self->{id} );
     }
 
@@ -179,8 +179,9 @@ sub update {
             my $refto =
               Emesinae::Message->lookup_msgid( $self->{dbh}, $r, Insert => 1 );
             $sth =
-              $self->{dbh}
-              ->prepare(q{INSERT OR IGNORE INTO refs (parent_id,child_id) VALUES (?1,?2)});
+              $self->{dbh}->prepare(
+q{INSERT OR IGNORE INTO refs (parent_id,child_id) VALUES (?1,?2)}
+              );
             $sth->execute( $refto->{id}, $self->{id} );
         }
     }
index 7c53a8cc740511881e1706a9adf8cd6b357989f4..06668e14a9fbae9ab5939bac150f8533918ed8e6 100644 (file)
@@ -49,11 +49,11 @@ $c{CGIPath} = "/cgi-bin/";
 $c{LockDir} = "/var/local/emesinae/locks/";
 
 $c{ReportingURL} = "http://bugs.example.com/Howto_Report_Bugs.html";
-# Optionally set this to the URL of a page offering advice/instructions for the 
+
+# Optionally set this to the URL of a page offering advice/instructions for the
 # control bot.
 #$c{ControlHelpURL} = "http://bugs.example.com/Control_Help.html";
 
-
 # <MSGID> is replaced by the real message id.
 %{ $c{Archives} } = (
     "marc.info" => "http://marc.info/?i=<MSGID>",
@@ -66,6 +66,7 @@ $c{ReportingURL} = "http://bugs.example.com/Howto_Report_Bugs.html";
 # ControlAllowPath should contain the path to a file with one email address per
 # line.
 $c{ControlAllowPath} = "/etc/emesinae/control.users";
+
 # Otherwise ControlAllow should be an array of email addresses
 #@{ $c{ControlAllow} } = qw/admin@example.com/;
 
index d9d37a7516bb3801da5bfe302db7f877ea6c1608..ca8cd41218d348118e42b0256cf8f3bf43d95c4d 100755 (executable)
@@ -231,7 +231,7 @@ sub lookup_bugid ($) {
 
     if ( $b eq "it" ) {
         die "No previous bug found" unless @bugs;
-        my $it = $bugs [ $#bugs ];
+        my $it = $bugs[$#bugs];
         $bugs{$it} = 0 unless $bugs{$it};
         return Emesinae::Bug->new( $dbh, ID => $it );
     }
@@ -270,7 +270,7 @@ sub cmd_title ($) {
     m/^(${MATCH_BUGID})\s+(.*)/ or die "Cannot parse arguments";
     my $b = lookup_bugid $1;
     push @reply, "Set title for #" . $b->{id} . " to `$2'";
-    $b->set_title( $2 );
+    $b->set_title($2);
     return 1;
 }
 
@@ -280,7 +280,7 @@ sub cmd_owner ($) {
     my $b = lookup_bugid $1;
     my $o = parse_address $2;
     push @reply, "Change owner for #" . $b->{id} . " to `$o'";
-    $b->set_owner( $o );
+    $b->set_owner($o);
     return 1;
 }
 
@@ -289,7 +289,7 @@ sub cmd_severity ($) {
     m/^(${MATCH_BUGID})\s+(.*)/ or die "Cannot parse arguments";
     my $b = lookup_bugid $1;
     push @reply, "Change severity for #" . $b->{id} . " to `$2'";
-    $b->set_severity( $2 );
+    $b->set_severity($2);
     return 1;
 }
 
@@ -300,7 +300,8 @@ sub cmd_affects ($) {
     if ( $2 eq "+" or $2 eq "" ) {
         push @reply, "Bug #" . $b->{id} . " affects `$3'";
         $b->set_tag( "affects", $3 );
-    } else {
+    }
+    else {
         push @reply, "Bug #" . $b->{id} . " does not affect `$3'";
         $b->clear_tag( "affects", $3 );
     }
index 2796562cfa00382611097df2926f1bf600ff99fc..693759f2e07aaeb9e398753e6997115220347e6c 100755 (executable)
@@ -54,7 +54,7 @@ my ( $sec, $min, $hour, $mday, $mon, $year ) =
   gmtime( $ENV{FAKE_RECEIVE_TIME} || time );
 
 my $queue = $map;
-my $id = time . $$;
+my $id    = time . $$;
 
 chdir("$c{SpoolDir}/incoming") || &failure("chdir to spool: $!");
 
@@ -63,7 +63,7 @@ umask(002);
 open( FILE, ">T.$id" ) || &failure("open temporary file: $!");
 
 my $envelope = <STDIN>;
-print(FILE $envelope) || &failure("write envelope to temporary file: $!");
+print( FILE $envelope ) || &failure("write envelope to temporary file: $!");
 
 printf( FILE
       "Received: (at %s) by $c{MailDomain}; %d %s %d %02d:%02d:%02d +0000\n",