Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2015-02-05 21:31:36 +0300
committerValery Sizov <valery@gitlab.com>2015-02-06 04:03:43 +0300
commit1ac20698a5122111c8e12de4cc59da837b0f9573 (patch)
tree67442cc67cf4d7aa4f3e0c66d11d4728eb4fa8ca /app/controllers/import/github_controller.rb
parent2d5765bd2ca9b7ce3e4251cb082cbc8c52e51996 (diff)
gitlab.com importer: refactorig
Diffstat (limited to 'app/controllers/import/github_controller.rb')
-rw-r--r--app/controllers/import/github_controller.rb22
1 files changed, 5 insertions, 17 deletions
diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb
index 08419a37476..108fc4396a6 100644
--- a/app/controllers/import/github_controller.rb
+++ b/app/controllers/import/github_controller.rb
@@ -1,4 +1,4 @@
-class Import::GithubController < ApplicationController
+class Import::GithubController < Import::BaseController
before_filter :github_auth, except: :callback
rescue_from Octokit::Unauthorized, with: :github_unauthorized
@@ -30,22 +30,10 @@ class Import::GithubController < ApplicationController
def create
@repo_id = params[:repo_id].to_i
repo = octo_client.repo(@repo_id)
- target_namespace = params[:new_namespace].presence || repo.owner.login
- existing_namespace = Namespace.find_by("path = ? OR name = ?", target_namespace, target_namespace)
-
- if existing_namespace
- if existing_namespace.owner == current_user
- namespace = existing_namespace
- else
- @already_been_taken = true
- @target_namespace = target_namespace
- @project_name = repo.name
- render and return
- end
- else
- namespace = Group.create(name: target_namespace, path: target_namespace, owner: current_user)
- namespace.add_owner(current_user)
- end
+ @target_namespace = params[:new_namespace].presence || repo.owner.login
+ @project_name = repo.name
+
+ namespace = get_or_create_namespace || (render and return)
@project = Gitlab::GithubImport::ProjectCreator.new(repo, namespace, current_user).execute
end