diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2017-06-10 04:29:15 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2017-06-10 04:29:15 +0000 |
commit | 06babbec7e788f2f3684f257ac817b424aedbf46 (patch) | |
tree | e2ac4ddcadfc164a720a9a055965443c01711367 /lib/redmine/scm | |
parent | 7f4767418befd064cfeb65b034eeeb2832a3c264 (diff) | |
download | redmine-06babbec7e788f2f3684f257ac817b424aedbf46.tar.gz redmine-06babbec7e788f2f3684f257ac817b424aedbf46.zip |
remove is_binary_data? from String (#25563)
git-svn-id: http://svn.redmine.org/redmine/trunk@16644 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/scm')
-rw-r--r-- | lib/redmine/scm/adapters/abstract_adapter.rb | 8 | ||||
-rw-r--r-- | lib/redmine/scm/adapters/git_adapter.rb | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb index 9ed8b25db..68fea1da4 100644 --- a/lib/redmine/scm/adapters/abstract_adapter.rb +++ b/lib/redmine/scm/adapters/abstract_adapter.rb @@ -430,6 +430,14 @@ module Redmine class Branch < String attr_accessor :revision, :scmid 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 diff --git a/lib/redmine/scm/adapters/git_adapter.rb b/lib/redmine/scm/adapters/git_adapter.rb index 1dd317d72..8d9821eed 100644 --- a/lib/redmine/scm/adapters/git_adapter.rb +++ b/lib/redmine/scm/adapters/git_adapter.rb @@ -338,7 +338,7 @@ module Redmine content = nil git_cmd(cmd_args) { |io| io.binmode; content = io.read } # git annotates binary files - return nil if content.is_binary_data? + return nil if ScmData.binary?(content) identifier = '' # git shows commit author on the first occurrence only authors_by_commit = {} |