diff --git a/CHANGELOG b/CHANGELOG index 52329ef928dc126fcfc06a6713b4c30d047d9857..b954cb383848af3da8558c3c481d3606ba1f55ac 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,7 @@ v 8.10.0 (unreleased) - Exclude email check from the standard health check - Fix changing issue state columns in milestone view - Add notification settings dropdown for groups + - Allow importing from Github using Personal Access Tokens. (Eric K Idema) - Fix user creation with stronger minimum password requirements !4054 (nathan-pmt) - PipelinesFinder uses git cache data - Check for conflicts with existing Project's wiki path when creating a new project. diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb index 95852c6941c11aea46d3a286ea8d96552eec109e..9c1b0eb20f43e005011e89889b41ca55c66844b1 100644 --- a/app/controllers/import/github_controller.rb +++ b/app/controllers/import/github_controller.rb @@ -1,6 +1,6 @@ class Import::GithubController < Import::BaseController before_action :verify_github_import_enabled - before_action :github_auth, except: [:callback, :new, :personal_access_token] + before_action :github_auth, only: [:status, :jobs, :create] rescue_from Octokit::Unauthorized, with: :github_unauthorized diff --git a/app/views/import/github/new.html.haml b/app/views/import/github/new.html.haml index b071d2214c2e2c5b591dd10e4c6db2169df7d495..435ed7bd4cb5c7b339a9cf5112f06dae345e9fbe 100644 --- a/app/views/import/github/new.html.haml +++ b/app/views/import/github/new.html.haml @@ -4,29 +4,35 @@ %h3.page-title = icon 'github', text: 'Import Projects from GitHub' -%p.light - To import a project from GitHub, you can use a - = link_to 'Personal Access Token', 'https://github.com/settings/tokens' - to access your GitHub account. When you create your Personal Access Token, +- if github_import_configured? + %p + To import a GitHub project, you first need to authorize GitLab to access + the list of your GitHub repositories: + + = link_to 'List Your GitHub Repositories', status_import_github_path, class: 'btn btn-success' + + %hr + +%p + - if github_import_configured? + Alternatively, + - else + To import a GitHub project, + you can use a + = succeed '.' do + = link_to 'Personal Access Token', 'https://github.com/settings/tokens' + When you create your Personal Access Token, you will need to select the <code>repo</code> scope, so we can display a list of your public and private repositories which are available for import. = form_tag personal_access_token_import_github_path, method: :post, class: 'form-inline' do .form-group = text_field_tag :personal_access_token, '', class: 'form-control', placeholder: "Personal Access Token", size: 40 - = submit_tag 'List Repositories', class: 'btn btn-create' + = submit_tag 'List Your GitHub Repositories', class: 'btn btn-success' -- if github_import_configured? - - unless logged_in_with_github? - %hr - %p.light - Note: If you go to - = link_to 'your profile', profile_account_path - and connect your account to GitHub, you can import projects without - generating a Personal Access Token. -- else +- unless github_import_configured? %hr - %p.light + %p Note: - if current_user.admin? As an administrator you may like to configure diff --git a/doc/workflow/importing/import_projects_from_github.md b/doc/workflow/importing/import_projects_from_github.md index 60894d52a7614d4c99f43e4688f0ebe6826675b8..a2b2a4b88f9d6690d525c207fa01be3d50f1958c 100644 --- a/doc/workflow/importing/import_projects_from_github.md +++ b/doc/workflow/importing/import_projects_from_github.md @@ -26,9 +26,11 @@ Click on the **GitHub** link and, if you are logged in via the GitHub integration, you will be redirected to GitHub for permission to access your projects. After accepting, you'll be automatically redirected to the importer. -If you are not using the GitHub integration, when you click the **GithHub** link -you'll be presented with instructions for creating Personal Access Token on -GitHub. Once you upload your token, you'll be taken to the importer. +If you are not using the GitHub integration, you can still perform a one-off +authorization with GitHub to access your projects. + +Alternatively, you can also enter a GitHub Personal Access Token. Once you enter +your token, you'll be taken to the importer.  diff --git a/features/dashboard/new_project.feature b/features/dashboard/new_project.feature index 32c88965bcf3b149ed8448268dce9db2841969ae..8ddafb6a7ac13c6b41789c92f9ee89462d539f5c 100644 --- a/features/dashboard/new_project.feature +++ b/features/dashboard/new_project.feature @@ -21,7 +21,7 @@ Background: Scenario: I should see instructions on how to import from GitHub Given I see "New Project" page When I click on "Import project from GitHub" - Then I am redirected to the Github import page + Then I am redirected to the GitHub import page @javascript Scenario: I should see Google Code import page diff --git a/features/steps/dashboard/new_project.rb b/features/steps/dashboard/new_project.rb index 0bd621da0f3b4c63d7863fe6c19e664bfe1cd9ae..09373168dadb615296ee129aef121057ffe25628 100644 --- a/features/steps/dashboard/new_project.rb +++ b/features/steps/dashboard/new_project.rb @@ -28,7 +28,7 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps first('.import_github').click end - step 'I am redirected to the Github import page' do + step 'I am redirected to the GitHub import page' do expect(current_path).to eq new_import_github_path end