Skip to content

Provide an existing namespace when importing project from GitHub

What does this MR do and why?

Currently, when we import a GitHub project to GitLab, we fall back to the user namespace if the target_namespace attribute is blank or does not exist.

In this MR we forbid passing a blank target_namespace attribute. We will also not create a new namespace or fall back to the user's namespace in case the target_namespace attribute contains not known namespace. The user needs to provide an existing namespace which can be their own user namespace or an existing group. If the conditions don't match we will return an error to the user.

The changes affect UI and API.

It resolves Import from GitHub API can ignore target_namespace

Screenshots or screen recordings

provide-existing-namespace-when-importing-GH-project

How to set up and validate locally

Use our API to import repository from GitHub:

  • If you leave target_namespace empty, you should see the error target_namespace is empty
  • If you put into target_namespace path that doesn't exist, you should see the error Namespace to import repository into does not exist. Please provide a different one.
  • If you put into target_namespace existed path (your own user namespace or an existing group that you have permission to import a project into) you'll get the success response and the project will be scheduled to import.

p.s. We can't verify the changes on UI because we can't specify a target_namespace that doesn't exist or pass a blank value for it.

MR acceptance checklist

Edited by Alex Kalderimis

Merge request reports