Step 2: Version Control for Snippets: Delete snippet repositories (MVP)
Important: All the new functionality must be implemented behind the feature flag
:version_snippets. Besides, it has to be scoped for projects. Therefore, instead of checking if the feature flag is enabled or not (
Feature.enabled?(:version_snippets)), we will check if the feature flag is enabled for specific projects (
Feature.enabled?(:version_snippets, project)). This way, for testing purposes, we can enable the feature flag on the project
gitlab-org/gitlab for example, instead of enabling it globally.
In this issue, we will add the functionality to delete the snippet repositories. This can happen when:
- the project is deleted
- the snippet is deleted
In order to delete the snippet repositories when the project is deleted, we will need to add them to the
Projects::DestroyService#trash_repositories!. The destroy happens in 2 steps:
- a move of the repository to a temporary place
- Async, the temporary directory is removed.
We could refactor the project's destroy service and avoid adding every kind of new repository we add. Comment in #13429 (comment 202162773).
When the snippet is deleted through the snippet's delete service, that we will implement in #39083 (closed), we will have to add the logic to remove the repository. It should work in a similar way that it does in the project deletion workflow. We cannot delete the repositories directly.