Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
8aafe685
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,发现更多精彩内容 >>
提交
8aafe685
编写于
3月 22, 2016
作者:
J
James Lopez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first round of fixes and spec fixes
上级
3b78885e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
39 addition
and
37 deletion
+39
-37
app/models/project.rb
app/models/project.rb
+3
-2
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+1
-18
lib/gitlab/bitbucket_import/importer_init.rb
lib/gitlab/bitbucket_import/importer_init.rb
+27
-0
lib/gitlab/bitbucket_import/key_deleter.rb
lib/gitlab/bitbucket_import/key_deleter.rb
+2
-11
lib/gitlab/bitbucket_import/project_creator.rb
lib/gitlab/bitbucket_import/project_creator.rb
+2
-2
spec/lib/gitlab/bitbucket_import/importer_spec.rb
spec/lib/gitlab/bitbucket_import/importer_spec.rb
+4
-4
未找到文件。
app/models/project.rb
浏览文件 @
8aafe685
...
...
@@ -407,7 +407,7 @@ class Project < ActiveRecord::Base
end
def
import_url
if
import_data
if
import_data
&&
super
import_url
=
Gitlab
::
ImportUrl
.
new
(
super
,
credentials:
import_data
.
credentials
)
import_url
.
full_url
else
...
...
@@ -417,7 +417,8 @@ class Project < ActiveRecord::Base
def
create_or_update_import_data
(
credentials
)
project_import_data
=
import_data
||
build_import_data
project_import_data
.
credentials
=
credentials
project_import_data
.
credentials
||=
{}
project_import_data
.
credentials
.
merge!
(
credentials
)
project_import_data
.
save
end
...
...
lib/gitlab/bitbucket_import/importer.rb
浏览文件 @
8aafe685
module
Gitlab
module
BitbucketImport
class
Importer
attr_reader
:project
,
:client
def
initialize
(
project
)
@project
=
project
if
import_data_credentials
&&
import_data_credentials
[
'bb_session'
]
token
=
import_data_credentials
[
'bb_session'
][
'bitbucket_access_token'
]
token_secret
=
import_data_credentials
[
'bb_session'
][
'bitbucket_access_token_secret'
]
@client
=
Client
.
new
(
token
,
token_secret
)
@formatter
=
Gitlab
::
ImportFormatter
.
new
else
raise
Projects
::
ImportService
::
Error
,
"Unable to find project import data credentials for project ID:
#{
@project
.
id
}
"
end
end
class
Importer
<
ImporterInit
def
execute
import_issues
if
has_issues?
...
...
@@ -27,10 +14,6 @@ module Gitlab
private
def
import_data_credentials
@import_data_credentials
||=
project
.
import_data
.
credentials
if
project
.
import_data
end
def
gl_user_id
(
project
,
bitbucket_id
)
if
bitbucket_id
user
=
User
.
joins
(
:identities
).
find_by
(
"identities.extern_uid = ? AND identities.provider = 'bitbucket'"
,
bitbucket_id
.
to_s
)
...
...
lib/gitlab/bitbucket_import/importer_init.rb
0 → 100644
浏览文件 @
8aafe685
module
Gitlab
module
BitbucketImport
class
ImporterInit
attr_reader
:project
,
:client
def
initialize
(
project
)
@project
=
project
if
import_data_credentials
&&
import_data_credentials
[
'bb_session'
]
token
=
import_data_credentials
[
'bb_session'
][
'bitbucket_access_token'
]
token_secret
=
import_data_credentials
[
'bb_session'
][
'bitbucket_access_token_secret'
]
@client
=
Client
.
new
(
token
,
token_secret
)
@formatter
=
Gitlab
::
ImportFormatter
.
new
else
raise
Projects
::
ImportService
::
Error
,
"Unable to find project import data credentials for project ID:
#{
@project
.
id
}
"
end
end
private
def
import_data_credentials
@import_data_credentials
||=
project
.
import_data
.
credentials
if
project
.
import_data
end
end
end
end
lib/gitlab/bitbucket_import/key_deleter.rb
浏览文件 @
8aafe685
module
Gitlab
module
BitbucketImport
class
KeyDeleter
attr_reader
:project
,
:current_user
,
:client
def
initialize
(
project
)
@project
=
project
@current_user
=
project
.
creator
import_data
=
project
.
import_data
.
try
(
:data
)
bb_session
=
import_data
[
"bb_session"
]
if
import_data
@client
=
Client
.
new
(
bb_session
[
"bitbucket_access_token"
],
bb_session
[
"bitbucket_access_token_secret"
])
end
class
KeyDeleter
<
ImporterInit
attr_reader
:current_user
def
execute
return
false
unless
BitbucketImport
.
public_key
.
present?
...
...
lib/gitlab/bitbucket_import/project_creator.rb
浏览文件 @
8aafe685
...
...
@@ -22,8 +22,8 @@ module Gitlab
import_source:
"
#{
repo
[
"owner"
]
}
/
#{
repo
[
"slug"
]
}
"
,
import_url:
"ssh://git@bitbucket.org/
#{
repo
[
"owner"
]
}
/
#{
repo
[
"slug"
]
}
.git"
,
).
execute
project
.
create_import_data
(
credentials:
{
"bb_session"
=>
session_data
}
)
import_data
=
project
.
import_data
import_data
.
credentials
.
merge!
(
"bb_session"
=>
session_data
)
project
end
end
...
...
spec/lib/gitlab/bitbucket_import/importer_spec.rb
浏览文件 @
8aafe685
...
...
@@ -34,9 +34,9 @@ describe Gitlab::BitbucketImport::Importer, lib: true do
let
(
:project_identifier
)
{
'namespace/repo'
}
let
(
:data
)
do
{
bb_session:
{
bitbucket_access_token:
"123456"
,
bitbucket_access_token_secret:
"secret"
'bb_session'
=>
{
'bitbucket_access_token'
=>
"123456"
,
'bitbucket_access_token_secret'
=>
"secret"
}
}
end
...
...
@@ -44,7 +44,7 @@ describe Gitlab::BitbucketImport::Importer, lib: true do
create
(
:project
,
import_source:
project_identifier
,
import_data:
ProjectImportData
.
new
(
data
:
data
)
import_data:
ProjectImportData
.
new
(
credentials
:
data
)
)
end
let
(
:importer
)
{
Gitlab
::
BitbucketImport
::
Importer
.
new
(
project
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录