| ... | @@ -10,38 +10,20 @@ end |
... | @@ -10,38 +10,20 @@ end |
|
|
#monkey patch raw_object from string
|
|
#monkey patch raw_object from string
|
|
|
Grit::GitRuby::Internal::RawObject.class_eval do
|
|
Grit::GitRuby::Internal::RawObject.class_eval do
|
|
|
def content
|
|
def content
|
|
|
transcoding(@content)
|
|
|
|
|
rescue Exception => ex
|
|
|
|
|
Rails.logger.error ex.message
|
|
|
|
|
@content
|
|
@content
|
|
|
end
|
|
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
|
|
end
|
|
|
|
|
|
|
|
return content
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
CharlockHolmes::Converter.convert(content, hash[:encoding], 'UTF-8') if hash[:encoding]
|
|
Grit::Diff.class_eval do
|
|
|
else
|
|
def old_path
|
|
|
content.force_encoding("UTF-8")
|
|
Gitlabhq::Encode.utf8 a_path
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
def new_path
|
|
|
|
Gitlabhq::Encode.utf8 b_path
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
Grit::Git.git_timeout = GIT_OPTS["git_timeout"]
|
|
Grit::Git.git_timeout = GIT_OPTS["git_timeout"]
|
|
|
Grit::Git.git_max_size = GIT_OPTS["git_max_size"] |
|
Grit::Git.git_max_size = GIT_OPTS["git_max_size"] |