Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a56496f1
Commit
a56496f1
authored
Feb 12, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ghe_importer' into 'master'
GHE importer See merge request !306
parents
1bf48360
88bf3c0f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
8 deletions
+42
-8
config/gitlab.yml.example
config/gitlab.yml.example
+4
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+20
-0
doc/integration/github.md
doc/integration/github.md
+15
-2
lib/gitlab/github_import/client.rb
lib/gitlab/github_import/client.rb
+2
-6
spec/controllers/import/github_controller_spec.rb
spec/controllers/import/github_controller_spec.rb
+1
-0
No files found.
config/gitlab.yml.example
View file @
a56496f1
...
...
@@ -258,8 +258,12 @@ production: &base
# args: { access_type: 'offline', approval_prompt: '' } }
# - { name: 'twitter', app_id: 'YOUR APP ID',
# app_secret: 'YOUR APP SECRET'}
# - { name: 'gitlab', app_id: 'YOUR APP ID',
# app_secret: 'YOUR APP SECRET',
# args: { scope: 'api' } }
# - { name: 'github', app_id: 'YOUR APP ID',
# app_secret: 'YOUR APP SECRET',
# url: "https://github.com/",
# args: { scope: 'user:email' } }
...
...
config/initializers/1_settings.rb
View file @
a56496f1
...
...
@@ -91,6 +91,26 @@ Settings['omniauth'] ||= Settingslogic.new({})
Settings
.
omniauth
[
'enabled'
]
=
false
if
Settings
.
omniauth
[
'enabled'
].
nil?
Settings
.
omniauth
[
'providers'
]
||=
[]
# Fill out omniauth-gitlab settings. It is needed for easy set up GHE or GH by just specifying url.
github_settings
=
Settings
.
omniauth
[
'providers'
].
find
{
|
provider
|
provider
[
"name"
]
==
"github"
}
if
github_settings
if
github_settings
[
"url"
].
include?
(
"https://github.com"
)
github_settings
[
"args"
][
"client_options"
]
=
{
"site"
=>
'https://api.github.com/'
,
"authorize_url"
=>
'https://github.com/login/oauth/authorize'
,
"token_url"
=>
'https://github.com/login/oauth/access_token'
}
else
github_settings
[
"args"
][
"client_options"
]
=
{
"site"
=>
File
.
join
(
github_settings
[
"url"
],
"api/v3"
),
"authorize_url"
=>
File
.
join
(
github_settings
[
"url"
],
"login/oauth/authorize"
),
"token_url"
=>
File
.
join
(
github_settings
[
"url"
],
"login/oauth/access_token"
)
}
end
end
Settings
[
'issues_tracker'
]
||=
{}
#
...
...
doc/integration/github.md
View file @
a56496f1
...
...
@@ -33,10 +33,23 @@ To enable the GitHub OmniAuth provider you must register your application with G
```
- { name: 'github', app_id: 'YOUR APP ID',
app_secret: 'YOUR APP SECRET',
args: { scope: 'user:email' } }
app_secret: 'YOUR APP SECRET',
url: "https://github.com/",
args: { scope: 'user:email' } }
```
1.
If you want to use GitHub Enterprise then your configuration should look like the following:
```
- { name: 'github', app_id: 'YOUR APP ID',
app_secret: 'YOUR APP SECRET',
url: "https://github.example.com/",
args: { scope: 'user:email' } }
```
1.
Change 'YOUR APP ID' to the client ID from the GitHub application page from step 7.
1.
Change 'YOUR APP SECRET' to the client secret from the GitHub application page from step 7.
...
...
lib/gitlab/github_import/client.rb
View file @
a56496f1
...
...
@@ -12,7 +12,7 @@ module Gitlab
if
access_token
::
Octokit
.
auto_paginate
=
true
@api
=
::
Octokit
::
Client
.
new
(
access_token:
access_token
)
@api
=
::
Octokit
::
Client
.
new
(
access_token:
access_token
,
api_endpoint:
github_options
[
:site
]
)
end
end
...
...
@@ -46,11 +46,7 @@ module Gitlab
end
def
github_options
{
site:
'https://api.github.com'
,
authorize_url:
'https://github.com/login/oauth/authorize'
,
token_url:
'https://github.com/login/oauth/access_token'
}
config
[
"args"
][
"client_options"
].
deep_symbolize_keys
end
end
end
...
...
spec/controllers/import/github_controller_spec.rb
View file @
a56496f1
...
...
@@ -11,6 +11,7 @@ describe Import::GithubController do
it
"updates access token"
do
token
=
"asdasd12345"
Gitlab
::
GithubImport
::
Client
.
any_instance
.
stub
(
:get_token
).
and_return
(
token
)
Gitlab
::
GithubImport
::
Client
.
any_instance
.
stub
(
:github_options
).
and_return
({})
Gitlab
.
config
.
omniauth
.
providers
<<
OpenStruct
.
new
(
app_id:
"asd123"
,
app_secret:
"asd123"
,
name:
"github"
)
get
:callback
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment