bug fixes for show git log on detail pages feature
authorAndrew Dunstan <andrew@dunslane.net>
Sun, 9 Jan 2011 22:50:53 +0000 (14:50 -0800)
committerAndrew Dunstan <andrew@dunslane.net>
Sun, 9 Jan 2011 22:50:53 +0000 (14:50 -0800)
cgi-bin/show_log.pl
templates/log.tt

index 637599aa1095b0ae6ec314b9a3673fbe011f3cb8..bc1e5d46516438e2a21f008284433aef8db454fb 100755 (executable)
@@ -72,7 +72,7 @@ if ($system && $logdate)
        $sth->execute($system,$logdate);
        my $row=$sth->fetchrow_arrayref;
        $sth->finish;
-       $git_head_ref = $row>[9];
+       $git_head_ref = $row->[9];
        my $last_build_row;
        if ($git_head_ref)
        {
@@ -166,6 +166,9 @@ $template->process('log.tt',
                changed_this_run_logs => $changed_this_run_logs,
                changed_since_success_logs => $changed_since_success_logs,
                info_row => $info_row,
+           git_head_ref => $git_head_ref,
+           last_build_git_ref => $last_build_git_ref,
+           last_success_git_ref => $last_success_git_ref,
 
        });
 
@@ -194,20 +197,20 @@ 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 $gitlog = `$gitcmd --pretty="$format" $git_from..$git_to 2>&1`;
+                 'commit %H%nAuthor: %cN <%ce>%nDate: %cd UTC%n%n%w(80,4,4)%s%n%n%b%n';
+               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';
                foreach my $commit ( keys %commits )
                {
                        my $commitlog = 
-                         `$gitcmd -n 1--pretty="$format" $commit 2>&1`;
+                         `$gitcmd -n 1 --pretty=format:"$format" $commit 2>&1`;
                        push(@commit_logs,$commitlog);
                }
                @commit_logs = reverse (sort @commit_logs);
index eac3ed4cb35fc89f05be84a6327c1db4cdf1247a..1b3905c8963c5e19f733317c86af8085aac8b004 100644 (file)
@@ -90,6 +90,8 @@ commit <a href="[% giturl ; commitref %]">[% commitref %]</a>
 <a href="[% IF scm == 'git' ; giturl; changed.1; ELSE ; cvsurl ; changed.0; 'rev='; changed.1; END %]">[% changed.0 ; IF scm == 'cvs'; ' '; changed.1; END %]</a>
 [%- END -%]
 </pre>
+[% END %]
+[% IF changed_this_run_logs.0 %]
 <h5>Git log</h5>
 <blockquote><pre>
 [%- FOREACH clog IN changed_this_run_logs ; PROCESS gitlog -%]
@@ -111,6 +113,8 @@ not recorded
 <a href="[% IF scm == 'git' ; giturl; changed.1; ELSE ; cvsurl ; changed.0; 'rev='; changed.1; END %]">[% changed.0 ; IF scm == 'cvs'; ' '; changed.1; END %]</a>
 [%- END -%]
 </pre>
+[% END %]
+[% IF changed_since_success_logs.0 %]
 <h5>Git log</h5>
 <blockquote><pre>
 [%- FOREACH clog IN changed_since_success_logs ; PROCESS gitlog -%]