Refactor `app/models/repository` into separate classes and simplify/remove other reduntant classes
Summary
app/models/repository
is a complex object, because it is trying to solve everything for very different types of repository.
It also depends on Gitlab::GlRepository
and EE:Gitlab:GlRepository
which implements some parameters and differences for each repository type.
This is a huge indicator that it need to be split into the mentioned types
Improvements
We are building a new framework for Geo replication. Part of the work rely on having the things that are going to be replicated to have its own unique / unambiguous representation on the codebase as at least a PORO/ActiveModel.
Current Repository doesn not fit that definition, and if we decide to workaround with current architecture, it will just become even more complex.
Our current polymorphic repository does not test each "type" individually, we are really just testing project repositories.
Risks
We need to make sure we keep all methods that are shared by all repositories in a subclass, and move the unique ones to their respective classes. If we fail to identify a shared method, we may brake existing behavior. We should also double checking where it is used, so we replace for the correct repository type
Involved components
- app/models/repository
- ee/app/models/ee/repository
- everything that uses them
- lib/gitlab/gl_repository.rb
- ee/lib/gitlab/gl_repository.rb
Proposed tasks
This are the proposed tasks after the initial investigation (see in comments below)
-
Split ::Repository
into separate classes for each type !21359 (closed) -
Remove all usages of repo_type.project?
,repo_type.wiki?
-
Remove all usages of RepoType
andGitlab::GlRepository
in service classes (switch to each respectiveGitlab::Repository
) -
Merge RepoType functionality into each separate repository in Gitlab::Repository
-
Rethink gl_repository
usage inpost_service
to something that returns aGitlab::Repository
-
Extract non-shared methods from ::Repository
to its respective classes -
Check whether we can remove def project
from repository or keep it only on the classes that are tied to a project -
Rename and move ::Repository
toGitlab::Repository::BaseRepository