Select predecesor build on same branch - fixes bug reported by Tom Lane.
authorAndrew Dunstan <andrew@dunslane.net>
Mon, 10 Jan 2011 13:26:15 +0000 (05:26 -0800)
committerAndrew Dunstan <andrew@dunslane.net>
Mon, 10 Jan 2011 13:26:15 +0000 (05:26 -0800)
cgi-bin/show_log.pl
templates/log.tt

index bc1e5d46516438e2a21f008284433aef8db454fb..68ffa3d093eccb34784d0061f1ecd2e1eebeef0c 100755 (executable)
@@ -59,26 +59,27 @@ if ($system && $logdate)
        my $last_build_statement = q{
                select distinct on (sysname) sysname, snapshot, stage, git_head_ref 
         from build_status 
        my $last_build_statement = q{
                select distinct on (sysname) sysname, snapshot, stage, git_head_ref 
         from build_status 
-        where sysname = ? and snapshot < ? 
+        where sysname = ? and branch = ? and snapshot < ? 
         order by sysname, snapshot desc limit 1
        };
        my $last_success_statement = q{
                select distinct on (sysname) sysname, snapshot, git_head_ref 
         from build_status 
         order by sysname, snapshot desc limit 1
        };
        my $last_success_statement = q{
                select distinct on (sysname) sysname, snapshot, git_head_ref 
         from build_status 
-        where sysname = ? and snapshot < ? and stage = 'OK' 
+        where sysname = ? and branch = ? and snapshot < ? and stage = 'OK' 
         order by sysname, snapshot desc limit 1
        };
        my $sth=$db->prepare($statement);
        $sth->execute($system,$logdate);
        my $row=$sth->fetchrow_arrayref;
         order by sysname, snapshot desc limit 1
        };
        my $sth=$db->prepare($statement);
        $sth->execute($system,$logdate);
        my $row=$sth->fetchrow_arrayref;
-       $sth->finish;
+       $branch = $row->[5];
        $git_head_ref = $row->[9];
        $git_head_ref = $row->[9];
+       $sth->finish;
        my $last_build_row;
        if ($git_head_ref)
        {
                $last_build_row = 
                  $db->selectrow_hashref($last_build_statement,undef,
        my $last_build_row;
        if ($git_head_ref)
        {
                $last_build_row = 
                  $db->selectrow_hashref($last_build_statement,undef,
-                                                                $system,$logdate);
+                                                                $system,$branch,$logdate);
                $last_build_git_ref = $last_build_row->{git_head_ref}
                  if $last_build_row;
                
                $last_build_git_ref = $last_build_row->{git_head_ref}
                  if $last_build_row;
                
@@ -88,7 +89,7 @@ if ($system && $logdate)
        {
                $last_success_row =
                  $db->selectrow_hashref($last_success_statement,undef,
        {
                $last_success_row =
                  $db->selectrow_hashref($last_success_statement,undef,
-                                                                $system,$logdate);
+                                                                $system,$branch,$logdate);
                $last_success_git_ref = $last_success_row->{git_head_ref}
                  if $last_success_row;
        }
                $last_success_git_ref = $last_success_row->{git_head_ref}
                  if $last_success_row;
        }
@@ -97,7 +98,6 @@ if ($system && $logdate)
        $stage=$row->[2] || "unknown";
        $changed_this_run = $row->[3];
        $changed_since_success = $row->[4];
        $stage=$row->[2] || "unknown";
        $changed_this_run = $row->[3];
        $changed_since_success = $row->[4];
-       $branch = $row->[5];
        my $log_file_names = $row->[6];
        $scm = $row->[7];
        $scm ||= 'cvs'; # legacy scripts
        my $log_file_names = $row->[6];
        $scm = $row->[7];
        $scm ||= 'cvs'; # legacy scripts
index d53e61a33ced2fb29909c97ef6d7cbfc618606f4..07699b01900ee435bc50d868d288bf71c5644c5e 100644 (file)
@@ -30,6 +30,11 @@ See accompanying License file for license details
        firstline = loglines.shift;
        commitref = firstline.replace('commit ([0-9A-Fa-f]+)','$1');
 %]
        firstline = loglines.shift;
        commitref = firstline.replace('commit ([0-9A-Fa-f]+)','$1');
 %]
+<!--
+git_head_ref [% git_head_ref %]
+last_build_git_ref [% last_build_git_ref %]
+last_success_git_ref [% last_success_git_ref %]
+-->
 commit <a href="[% giturl ; commitref %]">[% commitref %]</a>
 [% loglines.join("\n")  | html %]
 
 commit <a href="[% giturl ; commitref %]">[% commitref %]</a>
 [% loglines.join("\n")  | html %]