diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-09 12:07:45 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-09 12:07:45 +0000 |
commit | ac1dca43baa7b3b1ac7d60d89ad60fdeefed0b80 (patch) | |
tree | 33aa23ddf7f18ddbfba3d006041c460de88583b7 /app/controllers | |
parent | f4186a753b86625a83e8499af14b5badd63a2ac2 (diff) | |
download | gitlab-ce-ac1dca43baa7b3b1ac7d60d89ad60fdeefed0b80.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/concerns/snippets_actions.rb | 7 | ||||
-rw-r--r-- | app/controllers/projects/snippets_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/repositories/git_http_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/snippets_controller.rb | 2 |
4 files changed, 17 insertions, 2 deletions
diff --git a/app/controllers/concerns/snippets_actions.rb b/app/controllers/concerns/snippets_actions.rb index bb46345d362..f80e891a558 100644 --- a/app/controllers/concerns/snippets_actions.rb +++ b/app/controllers/concerns/snippets_actions.rb @@ -28,4 +28,11 @@ module SnippetsActions def convert_line_endings(content) params[:line_ending] == 'raw' ? content : content.gsub(/\r\n/, "\n") end + + def check_repository_error + repository_error = snippet.errors.delete(:repository) + + flash.now[:alert] = repository_error if repository_error + recaptcha_check_with_fallback(repository_error.nil?) { render :edit } + end end diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index 8317d9fc6d5..241df8d95d7 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -62,7 +62,7 @@ class Projects::SnippetsController < Projects::ApplicationController service_response = Snippets::UpdateService.new(project, current_user, update_params).execute(@snippet) @snippet = service_response.payload[:snippet] - recaptcha_check_with_fallback { render :edit } + check_repository_error end def show diff --git a/app/controllers/repositories/git_http_controller.rb b/app/controllers/repositories/git_http_controller.rb index 5ce2ed77417..35ea77183b8 100644 --- a/app/controllers/repositories/git_http_controller.rb +++ b/app/controllers/repositories/git_http_controller.rb @@ -12,6 +12,8 @@ module Repositories rescue_from Gitlab::GitAccess::ProjectCreationError, with: :render_422_with_exception rescue_from Gitlab::GitAccess::TimeoutError, with: :render_503_with_exception + before_action :snippet_request_allowed? + # GET /foo/bar.git/info/refs?service=git-upload-pack (git pull) # GET /foo/bar.git/info/refs?service=git-receive-pack (git push) def info_refs @@ -116,6 +118,12 @@ module Repositories def log_user_activity Users::ActivityService.new(user).execute end + + def snippet_request_allowed? + if repo_type.snippet? && Feature.disabled?(:version_snippets, user) + render plain: 'The project you were looking for could not be found.', status: :not_found + end + end end end diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index e6840e46226..3f8b13dbcdd 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -64,7 +64,7 @@ class SnippetsController < ApplicationController service_response = Snippets::UpdateService.new(nil, current_user, update_params).execute(@snippet) @snippet = service_response.payload[:snippet] - recaptcha_check_with_fallback { render :edit } + check_repository_error end def show |