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:
authorJames Lopez <james@jameslopez.es>2016-05-03 14:14:31 +0300
committerJames Lopez <james@jameslopez.es>2016-05-03 14:14:31 +0300
commit3929972d900ee2b0eca806c36074c93ac83af2fd (patch)
tree0a6d347b5c32facc0a5d38645e24918b2cff7c98 /app/controllers/import
parent5a4f576359a71a57c70544568d9291cba53a2d39 (diff)
parente172028a3615d1a7f1520ce65cddcdf707a16e5f (diff)
Merge branch 'feature/project-import' of gitlab.com:gitlab-org/gitlab-ce into feature/project-export-ui-experimental
# Conflicts: # app/controllers/import/gitlab_project_controller.rb
Diffstat (limited to 'app/controllers/import')
-rw-r--r--app/controllers/import/gitlab_project_controller.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/controllers/import/gitlab_project_controller.rb b/app/controllers/import/gitlab_project_controller.rb
new file mode 100644
index 00000000000..ab0da196ac1
--- /dev/null
+++ b/app/controllers/import/gitlab_project_controller.rb
@@ -0,0 +1,45 @@
+class Import::GitlabProjectController < Import::BaseController
+ before_action :verify_gitlab_project_import_enabled
+ before_action :gitlab_project_auth, except: :callback
+
+ rescue_from OAuth::Error, with: :gitlab_project_unauthorized
+
+ #TODO permissions stuff
+
+ def callback
+
+ redirect_to status_import_gitlab_project_url
+ end
+
+ def status
+ @repos = client.projects
+ @incompatible_repos = client.incompatible_projects
+
+ @already_added_projects = current_user.created_projects.where(import_type: "gitlab_project")
+ already_added_projects_names = @already_added_projects.pluck(:import_source)
+
+ @repos.to_a.reject!{ |repo| already_added_projects_names.include? "#{repo["owner"]}/#{repo["slug"]}" }
+ end
+
+ def jobs
+ jobs = current_user.created_projects.where(import_type: "gitlab_project").to_json(only: [:id, :import_status])
+ render json: jobs
+ end
+
+ def create
+ @file = params[:file]
+
+ repo_owner = current_user.username
+ @target_namespace = params[:new_namespace].presence || repo_owner
+
+ # namespace = get_or_create_namespace || (render and return)
+
+ @project = Gitlab::ImportExport::ImportService.execute(archive_file: file, owner: repo_owner)
+ end
+
+ private
+
+ def verify_gitlab_project_import_enabled
+ render_404 unless gitlab_project_import_enabled?
+ end
+end