PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/gitlab/bitbucket_import/project_creator.rb

https://bitbucket.org/terrchen/gitlab-ce
Ruby | 37 lines | 33 code | 4 blank | 0 comment | 0 complexity | 4ca1961731d5f3f01c86d07224864feb MD5 | raw file
Possible License(s): Apache-2.0, CC0-1.0
  1. module Gitlab
  2. module BitbucketImport
  3. class ProjectCreator
  4. attr_reader :repo, :name, :namespace, :current_user, :session_data
  5. def initialize(repo, name, namespace, current_user, session_data)
  6. @repo = repo
  7. @name = name
  8. @namespace = namespace
  9. @current_user = current_user
  10. @session_data = session_data
  11. end
  12. def execute
  13. ::Projects::CreateService.new(
  14. current_user,
  15. name: name,
  16. path: name,
  17. description: repo.description,
  18. namespace_id: namespace.id,
  19. visibility_level: repo.visibility_level,
  20. import_type: 'bitbucket',
  21. import_source: repo.full_name,
  22. import_url: repo.clone_url(session_data[:token]),
  23. import_data: { credentials: session_data },
  24. skip_wiki: skip_wiki
  25. ).execute
  26. end
  27. private
  28. def skip_wiki
  29. repo.has_wiki?
  30. end
  31. end
  32. end
  33. end