From 35626e6efffd5660091d94d1599f12fc3ae83115 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Sat, 23 May 2009 18:19:08 +0000 Subject: Bug 487330: Links in comments pointing to patches should go to the 'diff' view rather than the plain text view, by default - Patch by uokrent@gmail.com r/a=LpSolit --- Bugzilla/Template.pm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 8c34bb493..3a46fad88 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -277,8 +277,8 @@ sub get_attachment_link { detaint_natural($attachid) || die "get_attachment_link() called with non-integer attachment number"; - my ($bugid, $isobsolete, $desc) = - $dbh->selectrow_array('SELECT bug_id, isobsolete, description + my ($bugid, $isobsolete, $desc, $is_patch) = + $dbh->selectrow_array('SELECT bug_id, isobsolete, description, ispatch FROM attachments WHERE attach_id = ?', undef, $attachid); @@ -296,9 +296,21 @@ sub get_attachment_link { $link_text =~ s/ \[details\]$//; my $linkval = "attachment.cgi?id=$attachid"; + + # If the attachment is a patch, try to link to the diff rather + # than the text, by default. + my $patchlink = ""; + if ($is_patch) { + # Determine if PatchReader is installed + my $patchviewer_installed = eval { require PatchReader; }; + if ($patchviewer_installed) { + $patchlink = '&action=diff'; + } + } + # Whitespace matters here because these links are in
 tags.
         return qq||
-               . qq|$link_text|
+               . qq|$link_text|
                . qq| [details]|
                . qq||;
     }
-- 
cgit v1.2.3-24-g4f1b