Class: Gitlab::GithubImport::Importer::CollaboratorImporter

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/github_import/importer/collaborator_importer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collaborator, project, client) ⇒ CollaboratorImporter

collaborator - An instance of ‘Gitlab::GithubImport::Representation::Collaborator` project - An instance of `Project` client - An instance of `Gitlab::GithubImport::Client`



12
13
14
15
16
17
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 12

def initialize(collaborator, project, client)
  @collaborator = collaborator
  @project = project
  @client = client
  @members_finder = ::MembersFinder.new(project, project.creator)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



7
8
9
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 7

def client
  @client
end

#collaboratorObject (readonly)

Returns the value of attribute collaborator.



7
8
9
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 7

def collaborator
  @collaborator
end

#members_finderObject (readonly)

Returns the value of attribute members_finder.



7
8
9
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 7

def members_finder
  @members_finder
end

#projectObject (readonly)

Returns the value of attribute project.



7
8
9
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 7

def project
  @project
end

Instance Method Details

#executeObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/github_import/importer/collaborator_importer.rb', line 19

def execute
  user_finder = GithubImport::UserFinder.new(project, client)
  user_id = user_finder.user_id_for(collaborator)
  return if user_id.nil?

  membership = existing_user_membership(user_id)
  access_level = map_access_level
  return if membership && membership[:access_level] >= map_access_level

  create_membership!(user_id, access_level)
end