PageRenderTime 24ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/gitlab/gitlab_import/project_creator.rb

https://gitlab.com/atanasmihaylov/gitlab-ce
Ruby | 30 lines | 27 code | 3 blank | 0 comment | 0 complexity | 48aecb63e203cbdfaa84e0294a9115d0 MD5 | raw file
  1. module Gitlab
  2. module GitlabImport
  3. class ProjectCreator
  4. attr_reader :repo, :namespace, :current_user, :session_data
  5. def initialize(repo, namespace, current_user, session_data)
  6. @repo = repo
  7. @namespace = namespace
  8. @current_user = current_user
  9. @session_data = session_data
  10. end
  11. def execute
  12. project = ::Projects::CreateService.new(
  13. current_user,
  14. name: repo["name"],
  15. path: repo["path"],
  16. description: repo["description"],
  17. namespace_id: namespace.id,
  18. visibility_level: repo["visibility_level"],
  19. import_type: "gitlab",
  20. import_source: repo["path_with_namespace"],
  21. import_url: repo["http_url_to_repo"].sub("://", "://oauth2:#{@session_data[:gitlab_access_token]}@")
  22. ).execute
  23. project
  24. end
  25. end
  26. end
  27. end