mirror of
https://github.com/redmine/redmine.git
synced 2025-11-02 11:25:55 +01:00
remove is_binary_data? from String (#25563)
git-svn-id: http://svn.redmine.org/redmine/trunk@16644 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -172,7 +172,7 @@ class RepositoriesController < ApplicationController
|
|||||||
return true if Redmine::MimeType.is_type?('text', path)
|
return true if Redmine::MimeType.is_type?('text', path)
|
||||||
# Ruby 1.8.6 has a bug of integer divisions.
|
# Ruby 1.8.6 has a bug of integer divisions.
|
||||||
# http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F
|
# http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F
|
||||||
return false if ent.is_binary_data?
|
return false if Redmine::Scm::Adapters::ScmData.binary?(ent)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
private :is_entry_text_data?
|
private :is_entry_text_data?
|
||||||
|
|||||||
@@ -4,8 +4,4 @@ require File.dirname(__FILE__) + '/string/inflections'
|
|||||||
class String #:nodoc:
|
class String #:nodoc:
|
||||||
include Redmine::CoreExtensions::String::Conversions
|
include Redmine::CoreExtensions::String::Conversions
|
||||||
include Redmine::CoreExtensions::String::Inflections
|
include Redmine::CoreExtensions::String::Inflections
|
||||||
|
|
||||||
def is_binary_data?
|
|
||||||
( self.count( "^ -~", "^\r\n" ).fdiv(self.size) > 0.3 || self.index( "\x00" ) ) unless empty?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -430,6 +430,14 @@ module Redmine
|
|||||||
class Branch < String
|
class Branch < String
|
||||||
attr_accessor :revision, :scmid
|
attr_accessor :revision, :scmid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module ScmData
|
||||||
|
def self.binary?(data)
|
||||||
|
unless data.empty?
|
||||||
|
data.count( "^ -~", "^\r\n" ).fdiv(data.size) > 0.3 || data.index( "\x00" )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ module Redmine
|
|||||||
content = nil
|
content = nil
|
||||||
git_cmd(cmd_args) { |io| io.binmode; content = io.read }
|
git_cmd(cmd_args) { |io| io.binmode; content = io.read }
|
||||||
# git annotates binary files
|
# git annotates binary files
|
||||||
return nil if content.is_binary_data?
|
return nil if ScmData.binary?(content)
|
||||||
identifier = ''
|
identifier = ''
|
||||||
# git shows commit author on the first occurrence only
|
# git shows commit author on the first occurrence only
|
||||||
authors_by_commit = {}
|
authors_by_commit = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user