Use Wiki instance as repository container
Before we started working on group wikis, `ProjectWiki` used a `Project` instance as the container of its `Repository` instance, so for group wikis we did the same with `Group`. This initially made sense and also mostly aligned with the semantics for `Repository#container`, but while working on wiki diffing [1] we noticed that the `Commit` and `Blob` classes sometimes use `container#repository`, which breaks some assumptions and also causes redundant Gitaly calls to the project repository when diffing wikis. Refactoring those classes is a lot riskier and would affect other features too, so in this commit we're instead changing the `Repository#container` to be the wiki instance, rather than the project or group. This generally seems to make sense anyway, and only needs some small adjustments. To satisfy the interface for `Repository#container`, we need to add or tweak some methods: - `Wiki.find_by_id` - `Wiki#id` - `Wiki#to_global_id` We also still need to be able to resolve wiki repositories from their containers, this is handled in the repository resolver for `Gitlab::GlRepository::WIKI`. [1] https://gitlab.com/gitlab-org/gitlab/-/merge_requests/35330
Showing
app/policies/wiki_policy.rb
0 → 100644
Please register or sign in to comment