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
diff options
context:
space:
mode:
authorMark Chao <mchao@gitlab.com>2018-09-06 05:59:52 +0300
committerMark Chao <mchao@gitlab.com>2018-10-30 10:44:55 +0300
commit6580de78bb52323fcafaaf4d2e770590e4f1c586 (patch)
treee310ab5c7342b82c1ce89d7653871b26758e88fd /app/models/blob.rb
parent6f0378485761ae476bf373b7cddb611da05caa9d (diff)
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.rb7
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