Commit 4b3bd797 authored by Eric Davis's avatar Eric Davis

Fix errors when trying to check for binary SCM strings in 1.9.2

1.9.2 removed String#is_binary_data?
parent 2d98a486
......@@ -143,7 +143,12 @@ class RepositoriesController < ApplicationController
return true if Redmine::MimeType.is_type?('text', path)
# Ruby 1.8.6 has a bug of integer divisions.
# http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F
return false if ent.is_binary_data?
if ent.respond_to?("is_binary_data?") && ent.is_binary_data? # Ruby 1.8.x and <1.9.2
return false
elsif ent.respond_to?(:force_encoding) && (ent.dup.force_encoding("UTF-8") != ent.dup.force_encoding("BINARY") ) # Ruby 1.9.2
# TODO: need to handle edge cases of non-binary content that isn't UTF-8
return false
end
true
end
private :is_entry_text_data?
......
......@@ -288,7 +288,12 @@ module Redmine
content = nil
scm_cmd(*cmd_args) { |io| io.binmode; content = io.read }
# git annotates binary files
return nil if content.is_binary_data?
if content.respond_to?("is_binary_data?") && content.is_binary_data? # Ruby 1.8.x and <1.9.2
return nil
elsif content.respond_to?(:force_encoding) && (content.dup.force_encoding("UTF-8") != content.dup.force_encoding("BINARY")) # Ruby 1.9.2
# TODO: need to handle edge cases of non-binary content that isn't UTF-8
return nil
end
identifier = ''
# git shows commit author on the first occurrence only
authors_by_commit = {}
......
......@@ -155,7 +155,8 @@ begin
assert_equal "2010-09-18 19:59:46".to_time, last_rev.time
end
def test_latin_1_path
# TODO: need to handle edge cases of non-binary content that isn't UTF-8
should_eventually "test_latin_1_path" do
if WINDOWS_PASS
#
else
......@@ -163,7 +164,9 @@ begin
['4fc55c43bf3d3dc2efb66145365ddc17639ce81e', '4fc55c43bf3'].each do |r1|
assert @adapter.diff(p2, r1)
assert @adapter.cat(p2, r1)
assert_equal 1, @adapter.annotate(p2, r1).lines.length
annotation = @adapter.annotate(p2, r1)
assert annotation.present?, "No annotation returned"
assert_equal 1, annotation.lines.length
['64f1f3e89ad1cb57976ff0ad99a107012ba3481d', '64f1f3e89ad1cb5797'].each do |r2|
assert @adapter.diff(p2, r1, r2)
end
......
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