Skip to content

Support Git access for group wikis

Markus Koller requested to merge 207869-group-wikis-git-support into master

What does this MR do?

Part of #207869 (closed), extracted from !42863 (closed).

This adds all the necessary routes and other behaviour to enable local Git access to group wiki repositories.

To handle lookups of the wiki container in Gitlab::RepoPath, we introduce a Routable.find_by_full_path helper to find routable objects without having to know their class.

Database changes

  • CaseSensitivity: A small tweak to allow passing an Arel::Attribute as a column, instead of just symbols.

  • Route: Added missing inverse_of: route, because it was causing redundant queries in some cases.

  • Routable.find_by_full_path: This was refactored to use the CaseSensitivity concern, and be callable directly on the module (when you don't care if the routable is a Project or Group). The existing queries are still the same, although formatted slightly differently.

    • Example SQL for Project.find_by_full_path('foo/bar', follow_redirects: true):

    • Example SQL for Routable.find_by_full_path('foo/bar', follow_redirects: true):

        SELECT "routes".* FROM "routes" WHERE "routes"."path" = 'foo/bar' LIMIT 1;
        SELECT "routes".* FROM "routes" WHERE (LOWER("routes"."path") = LOWER('foo/bar')) ORDER BY "routes"."id" ASC LIMIT 1;
        SELECT "redirect_routes".* FROM "redirect_routes" WHERE (LOWER("redirect_routes"."path") = LOWER('foo/bar')) LIMIT 1;
      • This is the new code path when Routable.find_by_full_path is called directly, and we use Route / RedirectRoute rather than the scoped join models.
      • These separate queries actually seem to perform much better than the combined join queries (a quick benchmark suggets it's almost twice as fast!), so it might be worth reusing this for other code paths in the future.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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
Edited by Markus Koller

Merge request reports