From 84ab785186f0fe9ce325331319b1d50dbef7d4c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?=
<%= @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