|
|
@ -9,17 +9,17 @@ module GitHelper
|
|
|
|
# 版本库文件内容,带转码
|
|
|
|
# 版本库文件内容,带转码
|
|
|
|
def git_fle_content(repo_path, path)
|
|
|
|
def git_fle_content(repo_path, path)
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
logger.info("git file content: repo_path is #{repo_path}, path is #{path}")
|
|
|
|
Rails.logger.info("git file content: repo_path is #{repo_path}, path is #{path}")
|
|
|
|
content = GitService.file_content(repo_path: repo_path, path: path)
|
|
|
|
content = GitService.file_content(repo_path: repo_path, path: path)
|
|
|
|
|
|
|
|
|
|
|
|
logger.info("git file content: content is #{content}")
|
|
|
|
Rails.logger.info("git file content: content is #{content}")
|
|
|
|
decode_content = nil
|
|
|
|
decode_content = nil
|
|
|
|
if content.present?
|
|
|
|
if content.present?
|
|
|
|
content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass
|
|
|
|
content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass
|
|
|
|
|
|
|
|
|
|
|
|
content = Base64.decode64(content)
|
|
|
|
content = Base64.decode64(content)
|
|
|
|
cd = CharDet.detect(content)
|
|
|
|
cd = CharDet.detect(content)
|
|
|
|
logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
|
|
|
|
Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
|
|
|
|
|
|
|
|
|
|
|
|
decode_content =
|
|
|
|
decode_content =
|
|
|
|
if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8
|
|
|
|
if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8
|
|
|
|