diff options
Diffstat (limited to 'app/controllers/import/gitlab_controller.rb')
-rw-r--r-- | app/controllers/import/gitlab_controller.rb | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/app/controllers/import/gitlab_controller.rb b/app/controllers/import/gitlab_controller.rb index 5ec8e9e6fc5..a95a67e208c 100644 --- a/app/controllers/import/gitlab_controller.rb +++ b/app/controllers/import/gitlab_controller.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class Import::GitlabController < Import::BaseController + extend ::Gitlab::Utils::Override + MAX_PROJECT_PAGES = 15 PER_PAGE_PROJECTS = 100 @@ -16,6 +18,8 @@ class Import::GitlabController < Import::BaseController # rubocop: disable CodeReuse/ActiveRecord def status + return super if Feature.enabled?(:new_import_ui) + @repos = client.projects(starting_page: 1, page_limit: MAX_PROJECT_PAGES, per_page: PER_PAGE_PROJECTS) @already_added_projects = find_already_added_projects('gitlab') @@ -37,7 +41,7 @@ class Import::GitlabController < Import::BaseController project = Gitlab::GitlabImport::ProjectCreator.new(repo, target_namespace, current_user, access_params).execute if project.persisted? - render json: ProjectSerializer.new.represent(project) + render json: ProjectSerializer.new.represent(project, serializer: :import) else render json: { errors: project_save_error(project) }, status: :unprocessable_entity end @@ -46,6 +50,29 @@ class Import::GitlabController < Import::BaseController end end + protected + + # rubocop: disable CodeReuse/ActiveRecord + override :importable_repos + def importable_repos + repos = client.projects(starting_page: 1, page_limit: MAX_PROJECT_PAGES, per_page: PER_PAGE_PROJECTS) + + already_added_projects_names = already_added_projects.map(&:import_source) + + repos.reject { |repo| already_added_projects_names.include? repo["path_with_namespace"] } + end + # rubocop: enable CodeReuse/ActiveRecord + + override :provider_name + def provider_name + :gitlab + end + + override :provider_url + def provider_url + 'https://gitlab.com' + end + private def client |