Search code examples
gitlabpid

Get GitLab repository URL via project ID


the idea is that the project ID wouldn't change, whereas the project path can change when a project is moved from namespace to a group/subgroup or any part is renamed.

The ID however is persistent (afaik).

I have found a few ways to get the project path via API, but I wonder if there's a way I could give a URL that uses the ID instead of the path, to send potential users to the repository front page, when referencing the project in a publication for example.

I can imagine a little webtool (http://www.gitlabidtourl.com/instance-url/id) that forwards/converts to a URL after getting the path via API. This would probably only work for public repositories though and using an external "translation" service seems impractical as well.


Solution

  • That is not yet supported, and is requested/followed with issue 339025

    As the project URLs are currently inextricably tied to the group structure, the URL of the project changes when groups or projects are moved.

    This causes problems in all cases where project URLs may be embedded in any source code.

    Proposal

    A super useful feature would be the ability to have a single static URL for each project, ideally just mapped to the project id (which is unique across the instance).

    This static URL must always point directly to the current location of the project, without any redirects in the middle. This static URL should, then, be the only URL that is referenced in any source code, as it will never change even when projects are moved.