summaryrefslogtreecommitdiff
path: root/app/controllers/import
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-03-31 16:34:13 +0200
committerDouwe Maan <douwe@gitlab.com>2015-03-31 16:34:13 +0200
commit737f322e41a640194b3df1a4c6cd2b1019268221 (patch)
treee9d0682ac0addad49826cd30a55e54d64a6e21bd /app/controllers/import
parent33a8f53f7a8fdc40d0f0ee4245258c8dba99198a (diff)
downloadgitlab-ce-737f322e41a640194b3df1a4c6cd2b1019268221.tar.gz
Import GitHub, Bitbucket or GitLab.com projects owned by authenticated user into current namespace.
Diffstat (limited to 'app/controllers/import')
-rw-r--r--app/controllers/import/bitbucket_controller.rb5
-rw-r--r--app/controllers/import/github_controller.rb5
-rw-r--r--app/controllers/import/gitlab_controller.rb5
3 files changed, 12 insertions, 3 deletions
diff --git a/app/controllers/import/bitbucket_controller.rb b/app/controllers/import/bitbucket_controller.rb
index 83ebc5fddca..bb8d7e0235c 100644
--- a/app/controllers/import/bitbucket_controller.rb
+++ b/app/controllers/import/bitbucket_controller.rb
@@ -36,8 +36,11 @@ class Import::BitbucketController < Import::BaseController
def create
@repo_id = params[:repo_id] || ""
repo = client.project(@repo_id.gsub("___", "/"))
- @target_namespace = params[:new_namespace].presence || repo["owner"]
@project_name = repo["slug"]
+
+ repo_owner = repo["owner"]
+ repo_owner = current_user.username if repo_owner == client.user["user"]["username"]
+ @target_namespace = params[:new_namespace].presence || repo_owner
namespace = get_or_create_namespace || (render and return)
diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb
index 8650b6464dc..87b41454c77 100644
--- a/app/controllers/import/github_controller.rb
+++ b/app/controllers/import/github_controller.rb
@@ -31,8 +31,11 @@ class Import::GithubController < Import::BaseController
def create
@repo_id = params[:repo_id].to_i
repo = client.repo(@repo_id)
- @target_namespace = params[:new_namespace].presence || repo.owner.login
@project_name = repo.name
+
+ repo_owner = repo.owner.login
+ repo_owner = current_user.username if repo_owner == client.user.login
+ @target_namespace = params[:new_namespace].presence || repo_owner
namespace = get_or_create_namespace || (render and return)
diff --git a/app/controllers/import/gitlab_controller.rb b/app/controllers/import/gitlab_controller.rb
index e979dad4b11..bddbfded812 100644
--- a/app/controllers/import/gitlab_controller.rb
+++ b/app/controllers/import/gitlab_controller.rb
@@ -28,8 +28,11 @@ class Import::GitlabController < Import::BaseController
def create
@repo_id = params[:repo_id].to_i
repo = client.project(@repo_id)
- @target_namespace = params[:new_namespace].presence || repo["namespace"]["path"]
@project_name = repo["name"]
+
+ repo_owner = repo["namespace"]["path"]
+ repo_owner = current_user.username if repo_owner == client.user["username"]
+ @target_namespace = params[:new_namespace].presence || repo_owner
namespace = get_or_create_namespace || (render and return)