Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
448817c4
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
448817c4
编写于
2月 17, 2015
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Load public key in initializer.
上级
ad6d6232
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
44 addition
and
15 deletion
+44
-15
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+13
-0
app/controllers/import/bitbucket_controller.rb
app/controllers/import/bitbucket_controller.rb
+5
-0
app/controllers/import/github_controller.rb
app/controllers/import/github_controller.rb
+5
-0
app/controllers/import/gitlab_controller.rb
app/controllers/import/gitlab_controller.rb
+5
-0
app/helpers/oauth_helper.rb
app/helpers/oauth_helper.rb
+2
-0
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+0
-12
config/initializers/public_key.rb
config/initializers/public_key.rb
+2
-0
lib/gitlab/bitbucket_import.rb
lib/gitlab/bitbucket_import.rb
+6
-0
lib/gitlab/bitbucket_import/key_adder.rb
lib/gitlab/bitbucket_import/key_adder.rb
+6
-3
未找到文件。
app/controllers/application_controller.rb
浏览文件 @
448817c4
...
...
@@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery
with: :exception
helper_method
:abilities
,
:can?
,
:current_application_settings
helper_method
:github_import_enabled?
,
:gitlab_import_enabled?
,
:bitbucket_import_enabled?
rescue_from
Encoding
::
CompatibilityError
do
|
exception
|
log_exception
(
exception
)
...
...
@@ -313,4 +314,16 @@ class ApplicationController < ActionController::Base
set_filter_values
(
merge_requests
)
merge_requests
end
def
github_import_enabled?
OauthHelper
.
enabled_oauth_providers
.
include?
(
:github
)
end
def
gitlab_import_enabled?
OauthHelper
.
enabled_oauth_providers
.
include?
(
:gitlab
)
end
def
bitbucket_import_enabled?
OauthHelper
.
enabled_oauth_providers
.
include?
(
:bitbucket
)
&&
Gitlab
::
BitbucketImport
.
public_key
.
present?
end
end
app/controllers/import/bitbucket_controller.rb
浏览文件 @
448817c4
class
Import::BitbucketController
<
Import
::
BaseController
before_filter
:verify_bitbucket_import_enabled
before_filter
:bitbucket_auth
,
except: :callback
# rescue_from OAuth::Error, with: :bitbucket_unauthorized
...
...
@@ -55,6 +56,10 @@ class Import::BitbucketController < Import::BaseController
@client
||=
Gitlab
::
BitbucketImport
::
Client
.
new
(
current_user
.
bitbucket_access_token
,
current_user
.
bitbucket_access_token_secret
)
end
def
verify_bitbucket_import_enabled
not_found!
unless
bitbucket_import_enabled?
end
def
bitbucket_auth
if
current_user
.
bitbucket_access_token
.
blank?
go_to_bitbucket_for_permissions
...
...
app/controllers/import/github_controller.rb
浏览文件 @
448817c4
class
Import::GithubController
<
Import
::
BaseController
before_filter
:verify_github_import_enabled
before_filter
:github_auth
,
except: :callback
rescue_from
Octokit
::
Unauthorized
,
with: :github_unauthorized
...
...
@@ -44,6 +45,10 @@ class Import::GithubController < Import::BaseController
@client
||=
Gitlab
::
GithubImport
::
Client
.
new
(
current_user
.
github_access_token
)
end
def
verify_github_import_enabled
not_found!
unless
github_import_enabled?
end
def
github_auth
if
current_user
.
github_access_token
.
blank?
go_to_github_for_permissions
...
...
app/controllers/import/gitlab_controller.rb
浏览文件 @
448817c4
class
Import::GitlabController
<
Import
::
BaseController
before_filter
:verify_gitlab_import_enabled
before_filter
:gitlab_auth
,
except: :callback
rescue_from
OAuth2
::
Error
,
with: :gitlab_unauthorized
...
...
@@ -41,6 +42,10 @@ class Import::GitlabController < Import::BaseController
@client
||=
Gitlab
::
GitlabImport
::
Client
.
new
(
current_user
.
gitlab_access_token
)
end
def
verify_gitlab_import_enabled
not_found!
unless
gitlab_import_enabled?
end
def
gitlab_auth
if
current_user
.
gitlab_access_token
.
blank?
go_to_gitlab_for_permissions
...
...
app/helpers/oauth_helper.rb
浏览文件 @
448817c4
...
...
@@ -20,4 +20,6 @@ module OauthHelper
def
additional_providers
enabled_oauth_providers
.
reject
{
|
provider
|
provider
.
to_s
.
starts_with?
(
'ldap'
)}
end
extend
self
end
app/helpers/projects_helper.rb
浏览文件 @
448817c4
...
...
@@ -265,16 +265,4 @@ module ProjectsHelper
"success"
end
end
def
github_import_enabled?
enabled_oauth_providers
.
include?
(
:github
)
end
def
gitlab_import_enabled?
enabled_oauth_providers
.
include?
(
:gitlab
)
end
def
bitbucket_import_enabled?
enabled_oauth_providers
.
include?
(
:bitbucket
)
end
end
config/initializers/public_key.rb
0 → 100644
浏览文件 @
448817c4
path
=
File
.
expand_path
(
"~/.ssh/id_rsa.pub"
)
Gitlab
::
BitbucketImport
.
public_key
=
File
.
read
(
path
)
if
File
.
exist?
(
path
)
\ No newline at end of file
lib/gitlab/bitbucket_import.rb
0 → 100644
浏览文件 @
448817c4
module
Gitlab
module
BitbucketImport
mattr_accessor
:public_key
@public_key
=
nil
end
end
\ No newline at end of file
lib/gitlab/bitbucket_import/key_adder.rb
浏览文件 @
448817c4
...
...
@@ -9,13 +9,16 @@ module Gitlab
end
def
execute
return
false
unless
BitbucketImport
.
public_key
.
present?
project_identifier
=
"
#{
repo
[
"owner"
]
}
/
#{
repo
[
"slug"
]
}
"
return
true
if
client
.
deploy_key
(
project_identifier
)
# TODO: Point to actual public key.
client
.
add_deploy_key
(
project_identifier
,
File
.
read
(
"/Users/douwemaan/.ssh/id_rsa.pub"
))
client
.
add_deploy_key
(
project_identifier
,
BitbucketImport
.
public_key
)
true
rescue
false
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录