Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
57c9a893
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,发现更多精彩内容 >>
提交
57c9a893
编写于
7月 15, 2018
作者:
S
Stan Hu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix assorted bugs and write spec for importing merge event
上级
eb482bfa
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
67 addition
and
5 deletion
+67
-5
lib/gitlab/bitbucket_server_import/importer.rb
lib/gitlab/bitbucket_server_import/importer.rb
+5
-3
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
+62
-2
未找到文件。
lib/gitlab/bitbucket_server_import/importer.rb
浏览文件 @
57c9a893
...
...
@@ -163,6 +163,8 @@ module Gitlab
target_branch_sha
=
pull_request
.
target_branch_sha
source_branch_sha
=
project
.
repository
.
commit
(
source_branch_sha
)
&
.
sha
||
source_branch_sha
target_branch_sha
=
project
.
repository
.
commit
(
target_branch_sha
)
&
.
sha
||
target_branch_sha
author
=
gitlab_user_id
(
project
,
pull_request
.
author_email
)
||
User
.
ghost
project
.
merge_requests
.
find_by
(
iid:
pull_request
.
iid
)
&
.
destroy
attributes
=
{
...
...
@@ -176,7 +178,7 @@ module Gitlab
target_branch:
Gitlab
::
Git
.
ref_name
(
pull_request
.
target_branch_name
),
target_branch_sha:
target_branch_sha
,
state:
pull_request
.
state
,
author_id:
gitlab_user_id
(
project
,
pull_request
.
author_email
)
,
author_id:
author
.
id
,
assignee_id:
nil
,
created_at:
pull_request
.
created_at
,
updated_at:
pull_request
.
updated_at
...
...
@@ -202,8 +204,8 @@ module Gitlab
def
import_merge_event
(
merge_request
,
merge_event
)
committer
=
merge_event
.
committer_email
user
=
User
.
ghost
user
||=
find_user_id
(
committer
)
if
committer
user
=
find_user_id
(
committer
)
if
committer
user
||=
User
.
ghost
timestamp
=
merge_event
.
merge_timestamp
metric
=
MergeRequest
::
Metrics
.
find_or_initialize_by
(
merge_request:
merge_request
)
metric
.
update_attributes
(
merged_by:
user
,
merged_at:
timestamp
)
...
...
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
浏览文件 @
57c9a893
...
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
BitbucketServerImport
::
Importer
do
include
ImportSpecHelper
let
(
:project
)
{
create
(
:project
,
import_url:
'http://my-bitbucket'
)
}
set
(
:project
)
{
create
(
:project
,
:repository
,
import_url:
'http://my-bitbucket'
)
}
subject
{
described_class
.
new
(
project
)
}
...
...
@@ -32,11 +32,71 @@ describe Gitlab::BitbucketServerImport::Importer do
end
end
# XXX We don't handle pull requests across forks
describe
'#import_pull_requests'
do
before
do
allow
(
subject
).
to
receive
(
:import_repository
)
allow
(
subject
).
to
receive
(
:delete_temp_branches
)
allow
(
subject
).
to
receive
(
:restore_branches
)
sample
=
RepoHelpers
.
sample_compare
pull_request
=
instance_double
(
BitbucketServer
::
Representation
::
PullRequest
,
iid:
10
,
source_branch_sha:
sample
.
commits
.
last
,
source_branch_name:
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
sample
.
source_branch
,
target_branch_sha:
sample
.
commits
.
first
,
target_branch_name:
Gitlab
::
Git
::
BRANCH_REF_PREFIX
+
sample
.
target_branch
,
title:
'This is a title'
,
description:
'This is a test pull request'
,
state:
'merged'
,
author:
'Test Author'
,
author_email:
project
.
owner
.
email
,
created_at:
Time
.
now
,
updated_at:
Time
.
now
,
merged?:
true
)
expect
(
subject
.
client
).
to
receive
(
:pull_requests
).
and_return
([
pull_request
])
@merge_event
=
instance_double
(
BitbucketServer
::
Representation
::
Activity
,
comment?:
false
,
merge_event?:
true
,
committer_email:
project
.
owner
.
email
,
merge_timestamp:
Time
.
now
)
@inline_comment
=
instance_double
(
BitbucketServer
::
Representation
::
Activity
,
comment?:
true
,
merge_event?:
false
)
@pr_comment
=
instance_double
(
BitbucketServer
::
Representation
::
Activity
,
comment?:
true
,
merge_event?:
false
)
end
it
'handles merge event'
do
expect
(
subject
.
client
).
to
receive
(
:activities
).
and_return
([
@merge_event
])
expect
{
subject
.
execute
}.
to
change
{
MergeRequest
.
count
}.
by
(
1
)
merge_request
=
MergeRequest
.
first
expect
(
merge_request
.
metrics
.
merged_by
).
to
eq
(
project
.
owner
)
expect
(
merge_request
.
metrics
.
merged_at
).
to
eq
(
@merge_event
.
merge_timestamp
)
end
context
'handles comments'
do
end
context
'handles diff comments'
do
end
context
'falls back to comments if diff comments'
do
end
context
'restores branches of inaccessible SHAs'
do
end
end
describe
'#delete_temp_branches'
do
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录