Make GlRepository the single source of truth for initialising Repository
What does this MR do?
This MR aims to begin centralising initialisation of ::Repository
throughout gitlab.
There are a growing number of repository types. The high level git repository interface is ::Repository
. The problem is that this class takes a large number of arguments, it is difficult to verify that it is working correctly, we often want to operate on all repo types of a container (e.g. Project
, Group
, Snippet
) and it is increasingly difficult to create new repository types as the number places that need modifying increases.
Here we cover the default basic case, access the current repository. There are several other use-cases that mean we have to manually create either ::Repository
or Gitlab::Git::Repository
(aka ::Repository#raw
). These cases are usually copy/move/delete operations where we want to operate on the previous or new git repository (as opposed to the current git repository). Because of these cases it seems easier to centralise on Gitlab::GlRepository
rather than allowing extra arguments on each container type (Project
, Group
, Snippet
) repository accessor.
Example cases that I want to cover with future refactoring:
-
https://gitlab.com/gitlab-org/gitlab/-/blob/678093c8b549e826bb83a9a5773b3dcce094aff7/app/models/project.rb#L1504 - Constructs
full_path
of repos before rename. Requires special knowledge of repo suffixes -
https://gitlab.com/gitlab-org/gitlab/-/blob/9b761ebbdd2f1c9164e4f04ad2601fe9b409eca5/app/services/projects/update_repository_storage_service.rb#L79 - Provides new
storage
to make raw gitaly calls. -
https://gitlab.com/gitlab-org/gitlab/-/blob/9b761ebbdd2f1c9164e4f04ad2601fe9b409eca5/app/services/projects/update_repository_storage_service.rb#L95 - Provides original
storage
to make raw gitaly calls. -
https://gitlab.com/gitlab-org/gitlab/-/blob/f9087286f31d4c29d0d579f024c7da6234df5c8a/ee/app/models/geo/deleted_project.rb#L20 - Constructs
full_path
of a deleted repo -
https://gitlab.com/gitlab-org/gitlab/-/blob/f9087286f31d4c29d0d579f024c7da6234df5c8a/ee/app/services/geo/repository_base_sync_service.rb#L216 - Constructs
disk_path
of a temporary repo
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team