diff options
author | Robert Speicher <robert@gitlab.com> | 2017-02-13 18:05:02 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-02-13 18:05:02 +0000 |
commit | da8577675843ea01e183bf07a635386e94514665 (patch) | |
tree | feb8a79efe2d71f9ad602e41cc1287f64edce60b /app/models | |
parent | 2fcc1f7e9eeb1cadbc264f4ae731f317f7581bc1 (diff) | |
parent | 948e1b845cd93c6450794379282712ec3b4a9caf (diff) | |
download | gitlab-ce-da8577675843ea01e183bf07a635386e94514665.tar.gz |
Merge branch 'dm-quick-fix-web-edit-new-lines' into 'master'
Respect autocrlf setting when creating/updating file through web UI
Closes gitlab-com/www-gitlab-com#1152
See merge request !9198
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/repository.rb | 8 |
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) |