Removed encoding monkey patch
This commit is contained in:
parent
52f6df7255
commit
b7558a2063
6 changed files with 46 additions and 45 deletions
|
@ -10,38 +10,20 @@ end
|
|||
#monkey patch raw_object from string
|
||||
Grit::GitRuby::Internal::RawObject.class_eval do
|
||||
def content
|
||||
transcoding(@content)
|
||||
rescue Exception => ex
|
||||
Rails.logger.error ex.message
|
||||
@content
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def transcoding(content)
|
||||
content ||= ""
|
||||
hash = CharlockHolmes::EncodingDetector.detect(content)
|
||||
|
||||
if hash
|
||||
return content if hash[:type] == :binary
|
||||
|
||||
if hash[:encoding] == "UTF-8"
|
||||
content = if hash[:confidence] < 100
|
||||
content
|
||||
else
|
||||
content.force_encoding("UTF-8")
|
||||
end
|
||||
|
||||
return content
|
||||
end
|
||||
|
||||
CharlockHolmes::Converter.convert(content, hash[:encoding], 'UTF-8') if hash[:encoding]
|
||||
else
|
||||
content.force_encoding("UTF-8")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Grit::Diff.class_eval do
|
||||
def old_path
|
||||
Gitlabhq::Encode.utf8 a_path
|
||||
end
|
||||
|
||||
def new_path
|
||||
Gitlabhq::Encode.utf8 b_path
|
||||
end
|
||||
end
|
||||
|
||||
Grit::Git.git_timeout = GIT_OPTS["git_timeout"]
|
||||
Grit::Git.git_max_size = GIT_OPTS["git_max_size"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue