Commit 9ae21465 authored by Mark Chao's avatar Mark Chao

Refactor project_or_wiki to container

With container concept in GitAccess,
EE::GitlabAccessWiki override is no longer needed.
parent 8fc3e503
...@@ -5,24 +5,24 @@ module EE ...@@ -5,24 +5,24 @@ module EE
include ::ProjectsHelper include ::ProjectsHelper
include ::ApplicationSettingsHelper include ::ApplicationSettingsHelper
def geo_primary_web_url(project_or_wiki) def geo_primary_web_url(repository_container)
File.join(::Gitlab::Geo.primary_node.url, project_or_wiki.full_path) File.join(::Gitlab::Geo.primary_node.url, repository_container.full_path)
end end
def geo_primary_ssh_url_to_repo(project_or_wiki) def geo_primary_ssh_url_to_repo(repository_container)
"#{::Gitlab::Geo.primary_node.clone_url_prefix}#{project_or_wiki.full_path}.git" "#{::Gitlab::Geo.primary_node.clone_url_prefix}#{repository_container.full_path}.git"
end end
def geo_primary_http_url_to_repo(project_or_wiki) def geo_primary_http_url_to_repo(repository_container)
geo_primary_web_url(project_or_wiki) + '.git' geo_primary_web_url(repository_container) + '.git'
end end
def geo_primary_default_url_to_repo(project_or_wiki) def geo_primary_default_url_to_repo(repository_container)
case default_clone_protocol case default_clone_protocol
when 'ssh' when 'ssh'
geo_primary_ssh_url_to_repo(project_or_wiki) geo_primary_ssh_url_to_repo(repository_container)
else else
geo_primary_http_url_to_repo(project_or_wiki) geo_primary_http_url_to_repo(repository_container)
end end
end end
......
...@@ -10,12 +10,6 @@ module EE ...@@ -10,12 +10,6 @@ module EE
GEO_SERVER_DOCS_URL = 'https://docs.gitlab.com/ee/administration/geo/replication/using_a_geo_server.html'.freeze GEO_SERVER_DOCS_URL = 'https://docs.gitlab.com/ee/administration/geo/replication/using_a_geo_server.html'.freeze
protected
def project_or_wiki
project
end
private private
def custom_action_for?(cmd) def custom_action_for?(cmd)
...@@ -61,18 +55,18 @@ module EE ...@@ -61,18 +55,18 @@ module EE
def geo_primary_url_to_repo def geo_primary_url_to_repo
case protocol case protocol
when 'ssh' when 'ssh'
geo_primary_ssh_url_to_repo(project_or_wiki) geo_primary_ssh_url_to_repo(container)
else else
geo_primary_http_url_to_repo(project_or_wiki) geo_primary_http_url_to_repo(container)
end end
end end
def primary_http_repo_url def primary_http_repo_url
geo_primary_http_url_to_repo(project_or_wiki) geo_primary_http_url_to_repo(container)
end end
def primary_ssh_url_to_repo def primary_ssh_url_to_repo
geo_primary_ssh_url_to_repo(project_or_wiki) geo_primary_ssh_url_to_repo(container)
end end
def current_replication_lag_message def current_replication_lag_message
......
# frozen_string_literal: true
module EE
module Gitlab
module GitAccessWiki
include GeoGitAccess
private
def project_or_wiki
project.wiki
end
end
end
end
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
module Gitlab module Gitlab
class GitAccessWiki < GitAccess class GitAccessWiki < GitAccess
prepend_if_ee('EE::Gitlab::GitAccessWiki') # rubocop: disable Cop/InjectEnterpriseEditionModule
ERROR_MESSAGES = { ERROR_MESSAGES = {
read_only: "You can't push code to a read-only GitLab instance.", read_only: "You can't push code to a read-only GitLab instance.",
write_to_wiki: "You are not allowed to write to this project's wiki." write_to_wiki: "You are not allowed to write to this project's wiki."
...@@ -33,10 +31,8 @@ module Gitlab ...@@ -33,10 +31,8 @@ module Gitlab
ERROR_MESSAGES[:read_only] ERROR_MESSAGES[:read_only]
end end
private def container
project.wiki
def repository
project.wiki.repository
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment