Fix treatment if gitweb URLs.
[buildfarm-server.git] / cgi-bin / show_log.pl
index 68ffa3d093eccb34784d0061f1ecd2e1eebeef0c..064337d882729f82cbedae043cb68e692753f1ef 100755 (executable)
@@ -38,6 +38,7 @@ my $conf = "";
 my ($stage,$changed_this_run,$changed_since_success,$sysinfo,$branch,$scmurl);
 my $scm;
 my ($git_head_ref, $last_build_git_ref, $last_success_git_ref);
+my ($stage_times, $run_time);
 
 use vars qw($info_row);
 
@@ -102,6 +103,8 @@ if ($system && $logdate)
        $scm = $row->[7];
        $scm ||= 'cvs'; # legacy scripts
        $scmurl = $row->[8];
+       $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;
@@ -111,7 +114,7 @@ if ($system && $logdate)
           select operating_system, os_version, 
                  compiler, compiler_version, 
                  architecture,
-                replace(owner_email,'\@',' [ a t ] ') as owner_email,
+                replace(owner_email,E'\@',' [ a t ] ') as owner_email,
                 sys_notes_ts::date AS sys_notes_date, sys_notes
           from buildsystems 
           where status = 'approved'
@@ -135,6 +138,21 @@ if ($system && $logdate)
            $info_row->{compiler_version} = $latest_personality->[1];
        }
        $sth->finish;
+       my $stage_times_query = q{
+           select log_stage, stage_duration
+           from build_status_log
+           where sysname = ? and snapshot = ?
+        };
+       $stage_times = 
+           $db->selectall_hashref($stage_times_query,'log_stage',undef,
+                                  $system,$logdate);
+       $stage_times_query = q{
+           select sum(stage_duration)
+           from build_status_log
+           where sysname = ? and snapshot = ?
+        };
+       ($run_time) = $db->selectrow_array($stage_times_query,undef,
+                                  $system,$logdate);
        $db->disconnect;
 }
 
@@ -157,6 +175,8 @@ $template->process('log.tt',
                system => $system,
                branch => $branch,
                stage => $stage,
+               stage_times => $stage_times,
+               run_time => $run_time,
                urldt => $logdate,
                log_file_names => \@log_file_names,
                conf => $conf,
@@ -187,7 +207,7 @@ sub process_changed
     my @changed_rows;
        my %commits;
        my @commit_logs;
-       my $gitcmd = "TZ=UTC GIT_DIR=$local_git_clone git log --stat --date=local";
+       my $gitcmd = "TZ=UTC GIT_DIR=$local_git_clone git log --date=local";
     foreach (@lines)
     {
                next if ($scm eq 'cvs' and ! m!^(pgsql|master|REL\d_\d_STABLE)/!);
@@ -196,17 +216,14 @@ sub process_changed
     }
        if ($git_from && $git_to)
        {
-               my $format = 
-                 'commit %H%nAuthor: %cN <%ce>%nDate: %cd UTC%n%n%w(80,4,4)%s%n%n%b%n';
+               my $format = 'commit %h %cd UTC%w(160,2,2)%s';
                my $gitlog = `$gitcmd --pretty=format:"$format" $git_from..$git_to 2>&1`;
                @commit_logs = split(/(?=^commit)/m,$gitlog)
        }
        else
        {
                # normally we expect to have the git refs. this is just a fallback.
-               my $format = 
-                 'epoch: %at%ncommit %H%nAuthor: %cN <%ce>%nDate: %cd UTC%n%n' .
-                       '%w(80,4,4)%s%n%n%b%n';
+               my $format = 'epoch: %at%ncommit %h %cd UTC%w(160,2,2)%s';
                foreach my $commit ( keys %commits )
                {
                        my $commitlog =