diff options
author | Valery Sizov <valery@gitlab.com> | 2015-01-28 02:37:19 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-02-05 23:50:34 +0300 |
commit | 5194214e3a2f97accf0c8119b4cb39fd4fcef5db (patch) | |
tree | 7320257c4470abadd90a0f17fd92f408143b6bb1 /lib/gitlab/gitlab_import/project_creator.rb | |
parent | 0a9cab4ee65f2b42c56989698c401cab60d68b53 (diff) |
GitLab integration. Importer
Diffstat (limited to 'lib/gitlab/gitlab_import/project_creator.rb')
-rw-r--r-- | lib/gitlab/gitlab_import/project_creator.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/gitlab/gitlab_import/project_creator.rb b/lib/gitlab/gitlab_import/project_creator.rb new file mode 100644 index 00000000000..affd828e816 --- /dev/null +++ b/lib/gitlab/gitlab_import/project_creator.rb @@ -0,0 +1,39 @@ +module Gitlab + module GitlabImport + class ProjectCreator + attr_reader :repo, :namespace, :current_user + + def initialize(repo, namespace, current_user) + @repo = repo + @namespace = namespace + @current_user = current_user + end + + def execute + @project = Project.new( + name: repo["name"], + path: repo["path"], + description: repo["description"], + namespace: namespace, + creator: current_user, + visibility_level: repo["visibility_level"], + import_type: "gitlab", + import_source: repo["path_with_namespace"], + import_url: repo["http_url_to_repo"]#.sub("://", "://oauth2@#{current_user.gitlab_access_token}") + ) + + if @project.save! + @project.reload + + if @project.import_failed? + @project.import_retry + else + @project.import_start + end + end + + @project + end + end + end +end |