Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-02-13 19:35:25 +0300
committerDouwe Maan <douwe@selenight.nl>2017-02-13 19:35:25 +0300
commit948e1b845cd93c6450794379282712ec3b4a9caf (patch)
tree53b2e6d410fd026dad0476b65b4084ed9becd08b /app
parent79e8e6134f89c4a09a422ca128a7579d844f040c (diff)
Respect autocrlf setting when creating/updating file through web UI
Diffstat (limited to 'app')
-rw-r--r--app/models/repository.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index d2d92a064a4..56c582cd9be 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -1230,6 +1230,14 @@ class Repository
action[:content]
end
+ detect = CharlockHolmes::EncodingDetector.new.detect(content) if content
+
+ 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 self.autocrlf
+ end
+
oid = rugged.write(content, :blob)
index.add(path: path, oid: oid, mode: mode)