Skip to content

Repository Shortcuts: support remapping of Git repos via SSH

Problem to solve

Customer has legacy git repositories that have no namespace, but since GitLab requires a namespace, they need some way to map their old projects to the new GitLab URL. They have thousands of repositories that need to retain their original remote URLs due to automation.

Further details

They are going to work around this by using gitolite, modifying gitlab-shell, and hooking into SSH_ORIGINAL_COMMAND environment variable to remap the clone. For example, if we need to remap:

project.git => namespace/project.git

The clone request for project.git will appear as git-upload-pack project.git in SSH_ORIGINAL_COMMAND. They'll remap this to git-upload-pack namespace/project.git.

To avoid having to maintain this, we could support some sort of repository mapping that would automatically do this.

Proposal

Add a new Admin API for creating, deleting redirects to Git repos to permit Git repositories to be accessed over SSH or HTTP without a namespace. The API could (but doesn't need to) look like this:

  • GET /api/v4/git_redirects
  • PUT /api/v4/git_redirects/<short>?target=<namespace>/<project> (with project path or ID) (or does POST make more sense?)
  • DELETE /api/v4/git_redirects/<short>

When an SSH (or HTTP) connection tries to access ssh://example.com/<short>.git they will transparently access ssh://example.com/<namespace>/<project>.git

Edited by James Ramsay (ex-GitLab)