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
path: root/app
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2015-02-06 03:57:27 +0300
committerValery Sizov <valery@gitlab.com>2015-02-06 08:48:21 +0300
commitb3c90dd51418d0c41df4ccd57d9480ea44b35eec (patch)
tree48135878c66cfdca4a5c1c996cd8e210bf32e157 /app
parent85c2cb2a1980d494aef198c59e4f3859b2668ba3 (diff)
GitHub importer refactoring
Diffstat (limited to 'app')
-rw-r--r--app/controllers/import/github_controller.rb22
1 files changed, 7 insertions, 15 deletions
diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb
index 108fc4396a6..c869c7c86f3 100644
--- a/app/controllers/import/github_controller.rb
+++ b/app/controllers/import/github_controller.rb
@@ -4,16 +4,16 @@ class Import::GithubController < Import::BaseController
rescue_from Octokit::Unauthorized, with: :github_unauthorized
def callback
- token = client.auth_code.get_token(params[:code]).token
+ token = client.get_token(params[:code])
current_user.github_access_token = token
current_user.save
redirect_to status_import_github_url
end
def status
- @repos = octo_client.repos
- octo_client.orgs.each do |org|
- @repos += octo_client.repos(org.login)
+ @repos = client.repos
+ client.orgs.each do |org|
+ @repos += client.repos(org.login)
end
@already_added_projects = current_user.created_projects.where(import_type: "github")
@@ -29,7 +29,7 @@ class Import::GithubController < Import::BaseController
def create
@repo_id = params[:repo_id].to_i
- repo = octo_client.repo(@repo_id)
+ repo = client.repo(@repo_id)
@target_namespace = params[:new_namespace].presence || repo.owner.login
@project_name = repo.name
@@ -41,12 +41,7 @@ class Import::GithubController < Import::BaseController
private
def client
- @client ||= Gitlab::GithubImport::Client.new.client
- end
-
- def octo_client
- Octokit.auto_paginate = true
- @octo_client ||= Octokit::Client.new(access_token: current_user.github_access_token)
+ @client ||= Gitlab::GithubImport::Client.new(current_user.github_access_token)
end
def github_auth
@@ -56,10 +51,7 @@ class Import::GithubController < Import::BaseController
end
def go_to_github_for_permissions
- redirect_to client.auth_code.authorize_url({
- redirect_uri: callback_import_github_url,
- scope: "repo, user, user:email"
- })
+ redirect_to client.authorize_url(callback_import_github_url)
end
def github_unauthorized