Another instance of virtual bug that would strip plus from branch names.
[buildfarm-server.git] / cgi-bin / show_log.pl
index 75dd2e7c2dcfb4e6bb0243053b29d38ccb49e809..ab3d3cdb00050140c1a6cbda0eeac81ef973f127 100755 (executable)
@@ -16,7 +16,8 @@ use CGI;
 use vars qw($dbhost $dbname $dbuser $dbpass $dbport 
                        $template_dir @log_file_names $local_git_clone);
 
-require "$ENV{BFConfDir}/BuildFarmWeb.pl";
+use FindBin qw($RealBin);
+require "$RealBin/../BuildFarmWeb.pl";
 
 my $template_opts = { INCLUDE_PATH => $template_dir, EVAL_PERL => 1};
 my $template = new Template($template_opts);
@@ -58,16 +59,20 @@ if ($system && $logdate)
 
        };
        my $last_build_statement = q{
-               select distinct on (sysname) sysname, snapshot, stage, git_head_ref 
-        from build_status 
-        where sysname = ? and branch = ? and snapshot < ? 
-        order by sysname, snapshot desc limit 1
+               select git_head_ref 
+                from build_status 
+                where sysname = ? and branch = ?  and snapshot =
+                    (select max(snapshot)
+                    from build_status
+                    where sysname = ? and branch = ? and snapshot < ?)
        };
        my $last_success_statement = q{
-               select distinct on (sysname) sysname, snapshot, git_head_ref 
-        from build_status 
-        where sysname = ? and branch = ? and snapshot < ? and stage = 'OK' 
-        order by sysname, snapshot desc limit 1
+               select git_head_ref 
+                from build_status 
+                where sysname = ? and branch = ?  and snapshot =
+                    (select max(snapshot)
+                    from build_status
+                    where sysname = ? and branch = ? and snapshot < ? and stage = 'OK')
        };
        my $sth=$db->prepare($statement);
        $sth->execute($system,$logdate);
@@ -80,7 +85,7 @@ if ($system && $logdate)
        {
                $last_build_row = 
                  $db->selectrow_hashref($last_build_statement,undef,
-                                                                $system,$branch,$logdate);
+                                                                $system, $branch,$system,$branch,$logdate);
                $last_build_git_ref = $last_build_row->{git_head_ref}
                  if $last_build_row;
                
@@ -90,7 +95,7 @@ if ($system && $logdate)
        {
                $last_success_row =
                  $db->selectrow_hashref($last_success_statement,undef,
-                                                                $system,$branch,$logdate);
+                                                                $system,$branch,$system,$branch,$logdate);
                $last_success_git_ref = $last_success_row->{git_head_ref}
                  if $last_success_row;
        }
@@ -103,6 +108,9 @@ if ($system && $logdate)
        $scm = $row->[7];
        $scm ||= 'cvs'; # legacy scripts
        $scmurl = $row->[8];
+       $scmurl = undef unless $scmurl =~ /^http/; # slight sanity check
+       $scmurl = 'http://git.postgresql.org/gitweb?p=postgresql.git;a=commit;h=' 
+           if ($scmurl eq 'http://git.postgresql.org/git/postgresql.git');
        $log_file_names =~ s/^\{(.*)\}$/$1/;
        @log_file_names=split(',',$log_file_names)
            if $log_file_names;
@@ -233,4 +241,3 @@ sub process_changed
        }
                return (\@changed_rows,\@commit_logs);
 }
-