diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2019-03-18 17:51:11 +0100 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2019-03-26 13:21:03 +0100 |
commit | d36415b7545fff543f08a5175790e3a92f383475 (patch) | |
tree | b88dfef2992af721191b790ac7a5bc6f1b9eb90b /lib/api/helpers/internal_helpers.rb | |
parent | d64452ebfc262cfc1324fcaf116e74bc436413d3 (diff) | |
download | gitlab-ce-d36415b7545fff543f08a5175790e3a92f383475.tar.gz |
Allow multiple repositories per project
This changes the repository type from a binary `wiki?` to a type. So
we can have more than 2 repository types.
Now everywhere we called `.wiki?` and expected a boolean, we check
that type.
Diffstat (limited to 'lib/api/helpers/internal_helpers.rb')
-rw-r--r-- | lib/api/helpers/internal_helpers.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb index fe78049af87..3fd824877ae 100644 --- a/lib/api/helpers/internal_helpers.rb +++ b/lib/api/helpers/internal_helpers.rb @@ -5,9 +5,11 @@ module API module InternalHelpers attr_reader :redirected_path - def wiki? - set_project unless defined?(@wiki) # rubocop:disable Gitlab/ModuleWithInstanceVariables - @wiki # rubocop:disable Gitlab/ModuleWithInstanceVariables + delegate :wiki?, to: :repo_type + + def repo_type + set_project unless defined?(@repo_type) # rubocop:disable Gitlab/ModuleWithInstanceVariables + @repo_type # rubocop:disable Gitlab/ModuleWithInstanceVariables end def project @@ -67,10 +69,10 @@ module API # rubocop:disable Gitlab/ModuleWithInstanceVariables def set_project if params[:gl_repository] - @project, @wiki = Gitlab::GlRepository.parse(params[:gl_repository]) + @project, @repo_type = Gitlab::GlRepository.parse(params[:gl_repository]) @redirected_path = nil else - @project, @wiki, @redirected_path = Gitlab::RepoPath.parse(params[:project]) + @project, @repo_type, @redirected_path = Gitlab::RepoPath.parse(params[:project]) end end # rubocop:enable Gitlab/ModuleWithInstanceVariables @@ -78,7 +80,7 @@ module API # Project id to pass between components that don't share/don't have # access to the same filesystem mounts def gl_repository - Gitlab::GlRepository.gl_repository(project, wiki?) + repo_type.identifier_for_subject(project) end def gl_project_path @@ -92,7 +94,7 @@ module API # Return the repository depending on whether we want the wiki or the # regular repository def repository - if wiki? + if repo_type.wiki? project.wiki.repository else project.repository |