diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/controllers/concerns/snippets_actions.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/controllers/concerns/snippets_actions.rb')
-rw-r--r-- | app/controllers/concerns/snippets_actions.rb | 22 |
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 |