From ef396d08fc9af54f0e2c69da27d64e13064e0dfb Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 15 Feb 2012 00:41:36 +0200 Subject: [PATCH] Fixed encoding issue for diff. Reordered merge request commits --- app/controllers/merge_requests_controller.rb | 6 +++++- app/helpers/commits_helper.rb | 2 +- app/views/commits/_diffs.html.haml | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index b029344..8b39521 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -49,7 +49,11 @@ class MergeRequestsController < ApplicationController end 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 def diffs diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index a750e49..3ed8e8c 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -58,7 +58,7 @@ module CommitsHelper next if line.match(/^\-\-\- a/) 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(/^@@ -/) next if line_old == 1 && line_new == 1 diff --git a/app/views/commits/_diffs.html.haml b/app/views/commits/_diffs.html.haml index e3aa45d..29eae1c 100644 --- a/app/views/commits/_diffs.html.haml +++ b/app/views/commits/_diffs.html.haml @@ -1,6 +1,6 @@ .file_stats = render "commits/diff_head", :diffs => diffs - + - diffs.each_with_index do |diff, i| - next if diff.diff.empty? - file = (@commit.tree / diff.b_path) @@ -16,7 +16,7 @@ %br/ .diff_file_content - if file.text? - = render :partial => "commits/text_file", :locals => { :diff => diff, :index => i } + = render "commits/text_file", :diff => diff, :index => i - elsif file.image? .diff_file_content_image %img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} -- libgit2 0.21.2