diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2019-03-18 19:51:11 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2019-03-26 15:21:03 +0300 |
commit | d36415b7545fff543f08a5175790e3a92f383475 (patch) | |
tree | b88dfef2992af721191b790ac7a5bc6f1b9eb90b /app/controllers | |
parent | d64452ebfc262cfc1324fcaf116e74bc436413d3 (diff) |
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 'app/controllers')
-rw-r--r-- | app/controllers/projects/git_http_client_controller.rb | 14 | ||||
-rw-r--r-- | app/controllers/projects/git_http_controller.rb | 4 |
2 files changed, 12 insertions, 6 deletions
diff --git a/app/controllers/projects/git_http_client_controller.rb b/app/controllers/projects/git_http_client_controller.rb index d439db97252..55d5fce9214 100644 --- a/app/controllers/projects/git_http_client_controller.rb +++ b/app/controllers/projects/git_http_client_controller.rb @@ -78,7 +78,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController end def parse_repo_path - @project, @wiki, @redirected_path = Gitlab::RepoPath.parse("#{params[:namespace_id]}/#{params[:project_id]}") + @project, @repo_type, @redirected_path = Gitlab::RepoPath.parse("#{params[:namespace_id]}/#{params[:project_id]}") end def render_missing_personal_access_token @@ -89,13 +89,19 @@ class Projects::GitHttpClientController < Projects::ApplicationController end def repository - wiki? ? project.wiki.repository : project.repository + repo_type.repository_for(project) end def wiki? - parse_repo_path unless defined?(@wiki) + repo_type.wiki? + end - @wiki + def repo_type + parse_repo_path unless defined?(@repo_type) + # When there a project did not exist, the parsed repo_type would be empty. + # In that case, we want to continue with a regular project repository. As we + # could create the project if the user pushing is allowed to do so. + @repo_type || Gitlab::GlRepository::PROJECT end def handle_basic_authentication(login, password) diff --git a/app/controllers/projects/git_http_controller.rb b/app/controllers/projects/git_http_controller.rb index f28af42d1b7..e519cc1f158 100644 --- a/app/controllers/projects/git_http_controller.rb +++ b/app/controllers/projects/git_http_controller.rb @@ -55,7 +55,7 @@ class Projects::GitHttpController < Projects::GitHttpClientController def render_ok set_workhorse_internal_api_content_type - render json: Gitlab::Workhorse.git_http_ok(repository, wiki?, user, action_name) + render json: Gitlab::Workhorse.git_http_ok(repository, repo_type, user, action_name) end def render_403(exception) @@ -99,7 +99,7 @@ class Projects::GitHttpController < Projects::GitHttpClientController end def access_klass - @access_klass ||= wiki? ? Gitlab::GitAccessWiki : Gitlab::GitAccess + @access_klass ||= repo_type.access_checker_class end def project_path |