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:
Diffstat (limited to 'app/controllers/concerns/snippets_actions.rb')
-rw-r--r--app/controllers/concerns/snippets_actions.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/app/controllers/concerns/snippets_actions.rb b/app/controllers/concerns/snippets_actions.rb
index 048b18c5c61..5552fd663f7 100644
--- a/app/controllers/concerns/snippets_actions.rb
+++ b/app/controllers/concerns/snippets_actions.rb
@@ -55,10 +55,9 @@ module SnippetsActions
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def show
- conditionally_expand_blob(blob)
-
respond_to do |format|
format.html do
+ conditionally_expand_blob(blob)
@note = Note.new(noteable: @snippet, project: @snippet.project)
@noteable = @snippet
@@ -68,11 +67,14 @@ module SnippetsActions
end
format.json do
+ conditionally_expand_blob(blob)
render_blob_json(blob)
end
format.js do
if @snippet.embeddable?
+ conditionally_expand_blobs(blobs)
+
render 'shared/snippets/show'
else
head :not_found
@@ -109,13 +111,15 @@ module SnippetsActions
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def blob
- return unless snippet
+ @blob ||= blobs.first
+ end
- @blob ||= if snippet.empty_repo?
- snippet.blob
- else
- snippet.blobs.first
- end
+ def blobs
+ @blobs ||= if snippet.empty_repo?
+ [snippet.blob]
+ else
+ snippet.blobs
+ end
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
@@ -132,6 +136,8 @@ module SnippetsActions
end
def redirect_if_binary
+ return if Feature.enabled?(:snippets_binary_blob)
+
redirect_to gitlab_snippet_path(snippet) if blob&.binary?
end
end