Commit fa418f9a authored by Mark Chao's avatar Mark Chao

Revert "Refactor project_or_wiki to container"

This reverts commit 9ae21465,
in which the semantic of `container` is incorrect.
See https://gitlab.com/gitlab-org/gitlab/-/issues/218643
parent 204d3d33
......@@ -5,24 +5,24 @@ module EE
include ::ProjectsHelper
include ::ApplicationSettingsHelper
def geo_primary_web_url(repository_container)
File.join(::Gitlab::Geo.primary_node.url, repository_container.full_path)
def geo_primary_web_url(project_or_wiki)
File.join(::Gitlab::Geo.primary_node.url, project_or_wiki.full_path)
end
def geo_primary_ssh_url_to_repo(repository_container)
"#{::Gitlab::Geo.primary_node.clone_url_prefix}#{repository_container.full_path}.git"
def geo_primary_ssh_url_to_repo(project_or_wiki)
"#{::Gitlab::Geo.primary_node.clone_url_prefix}#{project_or_wiki.full_path}.git"
end
def geo_primary_http_url_to_repo(repository_container)
geo_primary_web_url(repository_container) + '.git'
def geo_primary_http_url_to_repo(project_or_wiki)
geo_primary_web_url(project_or_wiki) + '.git'
end
def geo_primary_default_url_to_repo(repository_container)
def geo_primary_default_url_to_repo(project_or_wiki)
case default_clone_protocol
when 'ssh'
geo_primary_ssh_url_to_repo(repository_container)
geo_primary_ssh_url_to_repo(project_or_wiki)
else
geo_primary_http_url_to_repo(repository_container)
geo_primary_http_url_to_repo(project_or_wiki)
end
end
......
......@@ -10,6 +10,12 @@ module EE
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
def custom_action_for(cmd)
......@@ -59,18 +65,18 @@ module EE
def geo_primary_url_to_repo
case protocol
when 'ssh'
geo_primary_ssh_url_to_repo(container)
geo_primary_ssh_url_to_repo(project_or_wiki)
else
geo_primary_http_url_to_repo(container)
geo_primary_http_url_to_repo(project_or_wiki)
end
end
def primary_http_repo_url
geo_primary_http_url_to_repo(container)
geo_primary_http_url_to_repo(project_or_wiki)
end
def primary_ssh_url_to_repo
geo_primary_ssh_url_to_repo(container)
geo_primary_ssh_url_to_repo(project_or_wiki)
end
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,6 +2,8 @@
module Gitlab
class GitAccessWiki < GitAccess
prepend_if_ee('EE::Gitlab::GitAccessWiki') # rubocop: disable Cop/InjectEnterpriseEditionModule
ERROR_MESSAGES = {
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."
......@@ -31,8 +33,10 @@ module Gitlab
ERROR_MESSAGES[:read_only]
end
def container
project.wiki
private
def repository
project.wiki.repository
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