diff options
author | James Lopez <james@jameslopez.es> | 2016-06-14 17:31:03 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-06-14 17:31:03 +0300 |
commit | 9ecebaaea16d206ed20a2f4fc0021a2145c873f5 (patch) | |
tree | 346f9df3661e5cd0e31116fa19270c8e0f3fc032 /lib/gitlab | |
parent | fe370b1c396cb3c290fcdb1d716a79ffe5c29169 (diff) |
adding notifications stuff and more refactoring for exporting projects
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/gitlab_import/project_creator.rb | 21 | ||||
-rw-r--r-- | lib/gitlab/import_export/project_creator.rb | 23 |
2 files changed, 21 insertions, 23 deletions
diff --git a/lib/gitlab/gitlab_import/project_creator.rb b/lib/gitlab/gitlab_import/project_creator.rb index 72b10f536ec..3d0418261bb 100644 --- a/lib/gitlab/gitlab_import/project_creator.rb +++ b/lib/gitlab/gitlab_import/project_creator.rb @@ -3,21 +3,24 @@ module Gitlab class ProjectCreator attr_reader :repo, :namespace, :current_user, :session_data - def initialize(namespace_id, current_user, file, project_path) - @namespace_id = namespace_id + def initialize(repo, namespace, current_user, session_data) + @repo = repo + @namespace = namespace @current_user = current_user - @file = file - @project_path = project_path + @session_data = session_data end def execute ::Projects::CreateService.new( current_user, - name: @project_path, - path: @project_path, - namespace_id: namespace_id, - import_type: "gitlab_project", - import_source: @file + name: repo["name"], + path: repo["path"], + description: repo["description"], + namespace_id: namespace.id, + visibility_level: repo["visibility_level"], + import_type: "gitlab", + import_source: repo["path_with_namespace"], + import_url: repo["http_url_to_repo"].sub("://", "://oauth2:#{@session_data[:gitlab_access_token]}@") ).execute end end diff --git a/lib/gitlab/import_export/project_creator.rb b/lib/gitlab/import_export/project_creator.rb index 801d4b4f43a..6f1e3867efb 100644 --- a/lib/gitlab/import_export/project_creator.rb +++ b/lib/gitlab/import_export/project_creator.rb @@ -2,26 +2,21 @@ module Gitlab module ImportExport class ProjectCreator - def initialize(namespace_id, current_user) - @repo = repo - @namespace = Namespace.find_by_id(namespace_id) + def initialize(namespace_id, current_user, file, project_path) + @namespace_id = namespace_id @current_user = current_user - @user_map = user_map + @file = file + @project_path = project_path end def execute ::Projects::CreateService.new( current_user, - name: repo.name, - path: repo.name, - description: repo.summary, - namespace: namespace, - creator: current_user, - visibility_level: Gitlab::VisibilityLevel::PUBLIC, - import_type: "google_code", - import_source: repo.name, - import_url: repo.import_url, - import_data: { data: { 'repo' => repo.raw_data, 'user_map' => user_map } } + name: @project_path, + path: @project_path, + namespace_id: namespace_id, + import_type: "gitlab_project", + import_source: @file ).execute end end |