Commit ef396d08 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fixed encoding issue for diff. Reordered merge request commits

parent 65e4ad31
...@@ -49,7 +49,11 @@ class MergeRequestsController < ApplicationController ...@@ -49,7 +49,11 @@ class MergeRequestsController < ApplicationController
end end
def commits def commits
@commits = @project.repo.commits_between(@merge_request.target_branch, @merge_request.source_branch).map {|c| Commit.new(c)} @commits = @project.repo.
commits_between(@merge_request.target_branch, @merge_request.source_branch).
map {|c| Commit.new(c)}.
sort_by(&:created_at).
reverse
end end
def diffs def diffs
......
...@@ -58,7 +58,7 @@ module CommitsHelper ...@@ -58,7 +58,7 @@ module CommitsHelper
next if line.match(/^\-\-\- a/) next if line.match(/^\-\-\- a/)
next if line.match(/^\+\+\+ b/) next if line.match(/^\+\+\+ b/)
full_line = html_escape(line.gsub(/\n/, '')) full_line = html_escape(line.gsub(/\n/, '')).force_encoding("UTF-8")
if line.match(/^@@ -/) if line.match(/^@@ -/)
next if line_old == 1 && line_new == 1 next if line_old == 1 && line_new == 1
......
.file_stats .file_stats
= render "commits/diff_head", :diffs => diffs = render "commits/diff_head", :diffs => diffs
- diffs.each_with_index do |diff, i| - diffs.each_with_index do |diff, i|
- next if diff.diff.empty? - next if diff.diff.empty?
- file = (@commit.tree / diff.b_path) - file = (@commit.tree / diff.b_path)
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
%br/ %br/
.diff_file_content .diff_file_content
- if file.text? - if file.text?
= render :partial => "commits/text_file", :locals => { :diff => diff, :index => i } = render "commits/text_file", :diff => diff, :index => i
- elsif file.image? - elsif file.image?
.diff_file_content_image .diff_file_content_image
%img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment