Class: Import::GithubController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/import/github_controller.rb

Instance Method Summary collapse

Instance Method Details

#callbackObject


7
8
9
10
# File 'app/controllers/import/github_controller.rb', line 7

def callback
  session[:github_access_token] = client.get_token(params[:code])
  redirect_to status_import_github_url
end

#createObject


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/import/github_controller.rb', line 25

def create
  @repo_id = params[:repo_id].to_i
  repo = client.repo(@repo_id)
  @project_name = repo.name

  repo_owner = repo.owner.
  repo_owner = current_user.username if repo_owner == client.user.
  @target_namespace = params[:new_namespace].presence || repo_owner

  namespace = get_or_create_namespace || (render and return)

  @project = Gitlab::GithubImport::ProjectCreator.new(repo, namespace, current_user, access_params).execute
end

#jobsObject


20
21
22
23
# File 'app/controllers/import/github_controller.rb', line 20

def jobs
  jobs = current_user.created_projects.where(import_type: "github").to_json(only: [:id, :import_status])
  render json: jobs
end

#statusObject


12
13
14
15
16
17
18
# File 'app/controllers/import/github_controller.rb', line 12

def status
  @repos = client.repos
  @already_added_projects = current_user.created_projects.where(import_type: "github")
  already_added_projects_names = @already_added_projects.pluck(:import_source)

  @repos.reject!{ |repo| already_added_projects_names.include? repo.full_name }
end