diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-25 12:09:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-25 12:09:10 +0300 |
commit | b98fa9ef3d5bead417ae2f325cb64637883264e9 (patch) | |
tree | 409f2002dd056f12d82d3959b3e6f012c4087123 /app/models | |
parent | 7e3005967df23a957fe1998c8de4f50b412e69e7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/blob_language_from_git_attributes.rb | 4 | ||||
-rw-r--r-- | app/models/snippet.rb | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/app/models/concerns/blob_language_from_git_attributes.rb b/app/models/concerns/blob_language_from_git_attributes.rb index 56e1276a220..01878e067b9 100644 --- a/app/models/concerns/blob_language_from_git_attributes.rb +++ b/app/models/concerns/blob_language_from_git_attributes.rb @@ -1,13 +1,11 @@ # frozen_string_literal: true -# Applicable for blob classes with project attribute module BlobLanguageFromGitAttributes extend ActiveSupport::Concern def language_from_gitattributes - return unless project + return unless repository&.exists? - repository = project.repository repository.gitattribute(path, 'gitlab-language') end end diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 814a88dbd09..745700b1c65 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -197,7 +197,11 @@ class Snippet < ApplicationRecord end def blob - @blob ||= Blob.decorate(SnippetBlob.new(self), nil) + @blob ||= Blob.decorate(SnippetBlob.new(self), self) + end + + def blobs + repository.ls_files(repository.root_ref).map { |file| Blob.lazy(self, repository.root_ref, file) } end def hook_attrs @@ -208,7 +212,7 @@ class Snippet < ApplicationRecord super.to_s end - def sanitized_file_name + def self.sanitized_file_name(file_name) file_name.gsub(/[^a-zA-Z0-9_\-\.]+/, '') end |