lib/gitlab_git/blob.rb in gitlab_git-7.2.9 vs lib/gitlab_git/blob.rb in gitlab_git-7.2.10
- old
+ new
@@ -125,13 +125,16 @@
if action == :remove
index.remove(file[:path])
else
content = file[:content]
+ detect = CharlockHolmes::EncodingDetector.new.detect(content) if content
- # When writing to the repo directly as we are doing here,
- # the `core.autocrlf` config isn't taken into account.
- content.gsub!("\r\n", "\n") if repository.autocrlf
+ unless detect && detect[:type] == :binary
+ # When writing to the repo directly as we are doing here,
+ # the `core.autocrlf` config isn't taken into account.
+ content.gsub!("\r\n", "\n") if repository.autocrlf
+ end
oid = repo.write(content, :blob)
index.add(path: file[:path], oid: oid, mode: 0100644)
end