d308a3f433
Project tools visibility level ## part of #19734 ![project_features_access_level](/uploads/81ec7185d4e61d7578652020209af925/project_features_access_level.png) ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [x] API support added - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5606
35 lines
1.1 KiB
Ruby
35 lines
1.1 KiB
Ruby
module Gitlab
|
|
module GithubImport
|
|
class ProjectCreator
|
|
attr_reader :repo, :namespace, :current_user, :session_data
|
|
|
|
def initialize(repo, namespace, current_user, session_data)
|
|
@repo = repo
|
|
@namespace = namespace
|
|
@current_user = current_user
|
|
@session_data = session_data
|
|
end
|
|
|
|
def execute
|
|
project = ::Projects::CreateService.new(
|
|
current_user,
|
|
name: repo.name,
|
|
path: repo.name,
|
|
description: repo.description,
|
|
namespace_id: namespace.id,
|
|
visibility_level: repo.private ? Gitlab::VisibilityLevel::PRIVATE : ApplicationSetting.current.default_project_visibility,
|
|
import_type: "github",
|
|
import_source: repo.full_name,
|
|
import_url: repo.clone_url.sub("https://", "https://#{@session_data[:github_access_token]}@")
|
|
).execute
|
|
|
|
# If repo has wiki we'll import it later
|
|
if repo.has_wiki? && project
|
|
project.project_feature.update_attribute(:wiki_access_level, ProjectFeature::DISABLED)
|
|
end
|
|
|
|
project
|
|
end
|
|
end
|
|
end
|
|
end
|