The GitLab backend is written primarily with Rails so it uses Rails routing. Beside Rails best practices, there are few rules unique to the GitLab application. To support subgroups, GitLab project and group routes use the wildcard character to match project and group routes. For example, we might have a path such as:


However, paths can be ambiguous. Consider the following example:


It's ambiguous whether there is a subgroup named edit or whether this is a special endpoint to edit the gitlab-com group.

To eliminate the ambiguity and to make the backend easier to maintain, we introduced the /-/ scope. The purpose of it is to separate group or project paths from the rest of the routes. Also it helps to reduce the number of reserved names.

Global routes

We have a number of global routes. For example:


Group routes

Every group route must be under the /-/ scope.



To achieve that, use the scope '-' method.

Project routes

Every project route must be under the /-/ scope, except cases where a Git client or other software requires something different.



Changing existing routes

Don't change a URL to an existing page, unless it's necessary. If you must make a change, make it unnoticeable for users, because we don't want them to receive 404 Not Found if we can avoid it. This table should help:

URL description Example What to do
Can be used in scripts and automation snippet#raw Support both an old and new URL for one major release. Then, support a redirect from an old URL to a new URL for another major release.
Likely to be saved or shared issue#show Add a redirect from an old URL to a new URL until the next major release.
Limited use, unlikely to be shared admin#labels No extra steps required.

Migrating unscoped routes

Currently, the majority of routes are placed under the /-/ scope. However, you can help us migrate the rest of them! To migrate routes:

  1. Modify existing routes by adding - scope.
  2. Add redirects for legacy routes by using Gitlab::Routing.redirect_legacy_paths.
  3. Create a technical debt issue to remove deprecated routes in later releases.

To get started, see an example merge request.

Useful links