diff --git a/app/views/attachments/diff.html.erb b/app/views/attachments/diff.html.erb index f7f7bc9..1235ed6 100644 --- a/app/views/attachments/diff.html.erb +++ b/app/views/attachments/diff.html.erb @@ -13,6 +13,7 @@

<%= @diff_format_patch %>
+
<%= @diffstat_format_patch %>
<% end %> <%= render :partial => 'common/diff', :locals => {:diff => @diff, :diff_type => @diff_type, :diff_style => nil} %> diff --git a/lib/attachments_controller_patch.rb b/lib/attachments_controller_patch.rb index 0737f73..9e5e8ae 100644 --- a/lib/attachments_controller_patch.rb +++ b/lib/attachments_controller_patch.rb @@ -8,10 +8,13 @@ module AttachmentsControllerPatch @diff = File.new(@attachment.diskfile, "rb").read @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline' @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type) + @diff_format_patch = nil; + @diffstat_format_patch = nil; if (@diff.start_with?("From") and @diff.match(/(Subject.*)^---$/m)) @diff_format_patch = @diff.match(/(Subject.*)^---$/m)[0].sub(/^---$/m, '').force_encoding('UTF-8'); - else - @diff_format_patch = nil; + if (@diff.match(/^---$(.*?)^diff/m)) + @diffstat_format_patch = @diff.match(/^---$(.*?)^diff/m)[1].sub(/^---$/m, '').force_encoding('UTF-8').rstrip; + end end # Save diff type as user preference