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
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-08 15:06:01 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-08 15:06:01 +0300
commit9865665cb15a1f63e6c4d0623d33b8ef11810f8d (patch)
tree25458d0f21cf25896af750ed6933bbc4efcdb909 /app
parent77a7772c3bdb03d92cbc154f6b1a762953cc7c19 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/git_http_controller.rb16
-rw-r--r--app/helpers/diff_helper.rb11
-rw-r--r--app/models/namespace.rb6
-rw-r--r--app/models/project.rb15
4 files changed, 37 insertions, 11 deletions
diff --git a/app/controllers/projects/git_http_controller.rb b/app/controllers/projects/git_http_controller.rb
index 0c8c03cb16a..93f7ce73a51 100644
--- a/app/controllers/projects/git_http_controller.rb
+++ b/app/controllers/projects/git_http_controller.rb
@@ -6,10 +6,10 @@ class Projects::GitHttpController < Projects::GitHttpClientController
before_action :access_check
prepend_before_action :deny_head_requests, only: [:info_refs]
- rescue_from Gitlab::GitAccess::UnauthorizedError, with: :render_403
- rescue_from Gitlab::GitAccess::NotFoundError, with: :render_404
- rescue_from Gitlab::GitAccess::ProjectCreationError, with: :render_422
- rescue_from Gitlab::GitAccess::TimeoutError, with: :render_503
+ rescue_from Gitlab::GitAccess::UnauthorizedError, with: :render_403_with_exception
+ rescue_from Gitlab::GitAccess::NotFoundError, with: :render_404_with_exception
+ rescue_from Gitlab::GitAccess::ProjectCreationError, with: :render_422_with_exception
+ rescue_from Gitlab::GitAccess::TimeoutError, with: :render_503_with_exception
# GET /foo/bar.git/info/refs?service=git-upload-pack (git pull)
# GET /foo/bar.git/info/refs?service=git-receive-pack (git push)
@@ -58,19 +58,19 @@ class Projects::GitHttpController < Projects::GitHttpClientController
render json: Gitlab::Workhorse.git_http_ok(repository, repo_type, user, action_name)
end
- def render_403(exception)
+ def render_403_with_exception(exception)
render plain: exception.message, status: :forbidden
end
- def render_404(exception)
+ def render_404_with_exception(exception)
render plain: exception.message, status: :not_found
end
- def render_422(exception)
+ def render_422_with_exception(exception)
render plain: exception.message, status: :unprocessable_entity
end
- def render_503(exception)
+ def render_503_with_exception(exception)
render plain: exception.message, status: :service_unavailable
end
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 7f3e78f3a81..6aafd856423 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -60,9 +60,14 @@ module DiffHelper
if line.blank?
"&nbsp;".html_safe
else
- # We can't use `sub` because the HTML-safeness of `line` will not survive.
- line[0] = '' if line.start_with?('+', '-', ' ')
- line
+ # `sub` and substring-ing would destroy HTML-safeness of `line`
+ if line.start_with?('+', '-', ' ')
+ line.dup.tap do |line|
+ line[0] = ''
+ end
+ else
+ line
+ end
end
end
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 7c0220a705a..5663ebf8ba1 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -316,6 +316,12 @@ class Namespace < ApplicationRecord
Pages::VirtualDomain.new(all_projects_with_pages, trim_prefix: full_path)
end
+ def closest_setting(name)
+ self_and_ancestors(hierarchy_order: :asc)
+ .find { |n| !n.read_attribute(name).nil? }
+ .try(name)
+ end
+
private
def all_projects_with_pages
diff --git a/app/models/project.rb b/app/models/project.rb
index 6b8067ddd7d..29fe9aad62a 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -2250,8 +2250,23 @@ class Project < ApplicationRecord
Pages::LookupPath.new(self, trim_prefix: trim_prefix, domain: domain)
end
+ def closest_setting(name)
+ setting = read_attribute(name)
+ setting = closest_namespace_setting(name) if setting.nil?
+ setting = app_settings_for(name) if setting.nil?
+ setting
+ end
+
private
+ def closest_namespace_setting(name)
+ namespace.closest_setting(name)
+ end
+
+ def app_settings_for(name)
+ Gitlab::CurrentSettings.send(name) # rubocop:disable GitlabSecurity/PublicSend
+ end
+
def merge_requests_allowing_collaboration(source_branch = nil)
relation = source_of_merge_requests.opened.where(allow_collaboration: true)
relation = relation.where(source_branch: source_branch) if source_branch