Commit 5c28738d authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch '218643-fix-container-misuse' into 'master'

Revert "Refactor project_or_wiki to container"

See merge request gitlab-org/gitlab!32828
parents 9b1f6fb0 fa418f9a
...@@ -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(repository_container) def geo_primary_web_url(project_or_wiki)
File.join(::Gitlab::Geo.primary_node.url, repository_container.full_path) File.join(::Gitlab::Geo.primary_node.url, project_or_wiki.full_path)
end end
def geo_primary_ssh_url_to_repo(repository_container) def geo_primary_ssh_url_to_repo(project_or_wiki)
"#{::Gitlab::Geo.primary_node.clone_url_prefix}#{repository_container.full_path}.git" "#{::Gitlab::Geo.primary_node.clone_url_prefix}#{project_or_wiki.full_path}.git"
end end
def geo_primary_http_url_to_repo(repository_container) def geo_primary_http_url_to_repo(project_or_wiki)
geo_primary_web_url(repository_container) + '.git' geo_primary_web_url(project_or_wiki) + '.git'
end end
def geo_primary_default_url_to_repo(repository_container) def geo_primary_default_url_to_repo(project_or_wiki)
case default_clone_protocol case default_clone_protocol
when 'ssh' when 'ssh'
geo_primary_ssh_url_to_repo(repository_container) geo_primary_ssh_url_to_repo(project_or_wiki)
else else
geo_primary_http_url_to_repo(repository_container) geo_primary_http_url_to_repo(project_or_wiki)
end end
end end
......
...@@ -10,6 +10,12 @@ module EE ...@@ -10,6 +10,12 @@ 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)
...@@ -59,18 +65,18 @@ module EE ...@@ -59,18 +65,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(container) geo_primary_ssh_url_to_repo(project_or_wiki)
else else
geo_primary_http_url_to_repo(container) geo_primary_http_url_to_repo(project_or_wiki)
end end
end end
def primary_http_repo_url def primary_http_repo_url
geo_primary_http_url_to_repo(container) geo_primary_http_url_to_repo(project_or_wiki)
end end
def primary_ssh_url_to_repo def primary_ssh_url_to_repo
geo_primary_ssh_url_to_repo(container) geo_primary_ssh_url_to_repo(project_or_wiki)
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,6 +2,8 @@ ...@@ -2,6 +2,8 @@
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."
...@@ -31,8 +33,10 @@ module Gitlab ...@@ -31,8 +33,10 @@ module Gitlab
ERROR_MESSAGES[:read_only] ERROR_MESSAGES[:read_only]
end end
def container private
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