Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
2aa4d7f1
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,发现更多精彩内容 >>
提交
2aa4d7f1
编写于
7月 31, 2018
作者:
S
Stan Hu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug where fallback diff notes would not have an associated position
上级
0b91a533
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
7 deletion
+17
-7
lib/gitlab/bitbucket_server_import/importer.rb
lib/gitlab/bitbucket_server_import/importer.rb
+3
-3
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
+14
-4
未找到文件。
lib/gitlab/bitbucket_server_import/importer.rb
浏览文件 @
2aa4d7f1
...
...
@@ -253,15 +253,15 @@ module Gitlab
# Bitbucket Server supports the ability to comment on any line, not just the
# line in the diff. If we can't add the note as a DiffNote, fallback to creating
# a regular note.
create_fallback_diff_note
(
merge_request
,
comment
)
create_fallback_diff_note
(
merge_request
,
comment
,
position
)
rescue
StandardError
=>
e
errors
<<
{
type: :pull_request
,
id:
comment
.
id
,
errors:
e
.
message
}
nil
end
def
create_fallback_diff_note
(
merge_request
,
comment
)
def
create_fallback_diff_note
(
merge_request
,
comment
,
position
)
attributes
=
pull_request_comment_attributes
(
comment
)
attributes
[
:note
]
=
"*Comment on
file:
#{
comment
.
file_path
}
, old line:
#{
comment
.
old_pos
}
, new line:
#{
comment
.
new_pos
}
*
\n\n
"
+
attributes
[
:note
]
attributes
[
:note
]
=
"*Comment on
#{
position
.
old_path
}
:
#{
position
.
old_line
}
->
#{
position
.
new_path
}
:
#{
position
.
new_line
}
*
\n\n
"
+
attributes
[
:note
]
merge_request
.
notes
.
create!
(
attributes
)
end
...
...
spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
浏览文件 @
2aa4d7f1
...
...
@@ -178,6 +178,13 @@ describe Gitlab::BitbucketServerImport::Importer do
end
it
'falls back to comments if diff comments fail to validate'
do
reply
=
instance_double
(
BitbucketServer
::
Representation
::
Comment
,
author_email:
'someuser@gitlab.com'
,
note:
'I agree'
,
created_at:
now
,
updated_at:
now
)
# https://gitlab.com/gitlab-org/gitlab-test/compare/c1acaa58bbcbc3eafe538cb8274ba387047b69f8...5937ac0a7beb003549fc5fd26fc247ad
inline_note
=
instance_double
(
BitbucketServer
::
Representation
::
PullRequestComment
,
...
...
@@ -189,7 +196,7 @@ describe Gitlab::BitbucketServerImport::Importer do
new_pos:
9
,
note:
'This is a note with an invalid line position.'
,
author_email:
project
.
owner
.
email
,
comments:
[],
comments:
[
reply
],
created_at:
now
,
updated_at:
now
,
parent_comment:
nil
)
...
...
@@ -201,15 +208,18 @@ describe Gitlab::BitbucketServerImport::Importer do
merge_event?:
false
,
comment:
inline_note
)
allow
(
reply
).
to
receive
(
:parent_comment
).
and_return
(
inline_note
)
expect
(
subject
.
client
).
to
receive
(
:activities
).
and_return
([
inline_comment
])
expect
{
subject
.
execute
}.
to
change
{
MergeRequest
.
count
}.
by
(
1
)
merge_request
=
MergeRequest
.
first
expect
(
merge_request
.
notes
.
count
).
to
eq
(
1
)
note
=
merge_request
.
notes
.
first
expect
(
merge_request
.
notes
.
count
).
to
eq
(
2
)
note
s
=
merge_request
.
notes
expect
(
note
.
note
).
to
start_with
(
'*Comment on file:'
)
expect
(
notes
.
first
.
note
).
to
start_with
(
'*Comment on .gitmodules'
)
expect
(
notes
.
second
.
note
).
to
start_with
(
'*Comment on .gitmodules'
)
end
it
'restores branches of inaccessible SHAs'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录