diff options
author | Mark Chao <mchao@gitlab.com> | 2018-09-06 10:59:52 +0800 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-10-30 15:44:55 +0800 |
commit | 6580de78bb52323fcafaaf4d2e770590e4f1c586 (patch) | |
tree | e310ab5c7342b82c1ce89d7653871b26758e88fd /app/models/blob.rb | |
parent | 6f0378485761ae476bf373b7cddb611da05caa9d (diff) | |
download | gitlab-ce-6580de78bb52323fcafaaf4d2e770590e4f1c586.tar.gz |
Add access to Blob's language from gitattributes
Ported from Highlight class since it as a concept is more related to
blob, and this allows more flexibility.
Diffstat (limited to 'app/models/blob.rb')
-rw-r--r-- | app/models/blob.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/models/blob.rb b/app/models/blob.rb index 31a839274b5..e5854415dd2 100644 --- a/app/models/blob.rb +++ b/app/models/blob.rb @@ -184,6 +184,13 @@ class Blob < SimpleDelegator Gitlab::FileDetector.type_of(path) || Gitlab::FileDetector.type_of(name) end + def language_from_gitattributes + return nil unless project + + repository = project.repository + repository.gitattribute(path, 'gitlab-language') + end + def video? UploaderHelper::VIDEO_EXT.include?(extension) end |