[Step 3] Extract and refactor repository move logic from the Project model into the HasRepository concern
At the moment, all the logic to move repository storages from one place to another is located inside the Project
model. We need to extract and move them into the HasRepository
concern in order to make them available also for snippets and, in the future, for wikis.
Some of the methods I've seen are the following (but there can be more methods involved):
change_repository_storage
set_repository_writable!
set_repository_read_only!
-
git_transfer_in_progress?
. Instead of moving this method, we can add it to the concern and returnraise NotImplementedError
, and let any classes that include concern to implement it. The implementation would be just the linerepo_reference_count > 0
(this will make sense once we add/move the rest of the methods. -
reference_counter
.
We need also to create the methods:
-
repo_reference_count
. The implementation will be just:reference_counter(type: Gitlab::GlRepository::SNIPPET).value
We need to follow the logic in order to ensure we have the same method logic in projects and snippets after moving them to the concern, having in mind that we might need to readapt the functionality in the future for group wikis.
In #218992 (closed), we added the relation repository_storage_moves
to the snippet model. We need to move this relation to the HasRepository
concern as well. Nevertheless, we need to update the class:
attribute accordingly to the class that includes the concern. I think we can make a class method the HasRepository
concern, that then project and snippet can implement and return the proper value.