Class: Gitlab::FogbugzImport::ProjectCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/fogbugz_import/project_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, fb_session, namespace, current_user, user_map = nil) ⇒ ProjectCreator


6
7
8
9
10
11
12
# File 'lib/gitlab/fogbugz_import/project_creator.rb', line 6

def initialize(repo, fb_session, namespace, current_user, user_map = nil)
  @repo = repo
  @fb_session = fb_session
  @namespace = namespace
  @current_user = current_user
  @user_map = user_map
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user


4
5
6
# File 'lib/gitlab/fogbugz_import/project_creator.rb', line 4

def current_user
  @current_user
end

#fb_sessionObject (readonly)

Returns the value of attribute fb_session


4
5
6
# File 'lib/gitlab/fogbugz_import/project_creator.rb', line 4

def fb_session
  @fb_session
end

#namespaceObject (readonly)

Returns the value of attribute namespace


4
5
6
# File 'lib/gitlab/fogbugz_import/project_creator.rb', line 4

def namespace
  @namespace
end

#repoObject (readonly)

Returns the value of attribute repo


4
5
6
# File 'lib/gitlab/fogbugz_import/project_creator.rb', line 4

def repo
  @repo
end

#user_mapObject (readonly)

Returns the value of attribute user_map


4
5
6
# File 'lib/gitlab/fogbugz_import/project_creator.rb', line 4

def user_map
  @user_map
end

Instance Method Details

#executeObject


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab/fogbugz_import/project_creator.rb', line 14

def execute
  project = ::Projects::CreateService.new(
    current_user,
    name: repo.safe_name,
    path: repo.path,
    namespace: namespace,
    creator: current_user,
    visibility_level: Gitlab::VisibilityLevel::INTERNAL,
    import_type: 'fogbugz',
    import_source: repo.name,
    import_url: Project::UNKNOWN_IMPORT_URL
  ).execute

  project.create_or_update_import_data(data: { 'repo' => repo.raw_data, 'user_map' => user_map }, credentials: { fb_session: fb_session })

  project
end