diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /app/controllers/concerns/snippets_actions.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) | |
download | gitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'app/controllers/concerns/snippets_actions.rb')
-rw-r--r-- | app/controllers/concerns/snippets_actions.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/controllers/concerns/snippets_actions.rb b/app/controllers/concerns/snippets_actions.rb index 096c6efc0fc..e78723bdda2 100644 --- a/app/controllers/concerns/snippets_actions.rb +++ b/app/controllers/concerns/snippets_actions.rb @@ -53,10 +53,10 @@ module SnippetsActions def blob return unless snippet - @blob ||= if Feature.enabled?(:version_snippets, current_user) && !snippet.repository.empty? - snippet.blobs.first - else + @blob ||= if snippet.empty_repo? snippet.blob + else + snippet.blobs.first end end # rubocop:enable Gitlab/ModuleWithInstanceVariables @@ -65,11 +65,12 @@ module SnippetsActions params[:line_ending] == 'raw' ? content : content.gsub(/\r\n/, "\n") end - def check_repository_error - repository_errors = Array(snippet.errors.delete(:repository)) + def handle_repository_error(action) + errors = Array(snippet.errors.delete(:repository)) + + flash.now[:alert] = errors.first if errors.present? - flash.now[:alert] = repository_errors.first if repository_errors.present? - recaptcha_check_with_fallback(repository_errors.empty?) { render :edit } + recaptcha_check_with_fallback(errors.empty?) { render action } end def redirect_if_binary |