Skip to content

[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):

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.

Edited by Francisco Javier López