Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
014abc9c
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,发现更多精彩内容 >>
提交
014abc9c
编写于
6月 28, 2018
作者:
S
Stan Hu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle threaded comments and prepare for inline comments
上级
5728ffbf
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
118 addition
and
45 deletion
+118
-45
lib/bitbucket_server/representation/activity.rb
lib/bitbucket_server/representation/activity.rb
+13
-17
lib/bitbucket_server/representation/comment.rb
lib/bitbucket_server/representation/comment.rb
+61
-8
lib/bitbucket_server/representation/pull_request_comment.rb
lib/bitbucket_server/representation/pull_request_comment.rb
+38
-17
lib/gitlab/bitbucket_server_import/importer.rb
lib/gitlab/bitbucket_server_import/importer.rb
+6
-3
未找到文件。
lib/bitbucket_server/representation/activity.rb
浏览文件 @
014abc9c
...
...
@@ -13,31 +13,27 @@ module BitbucketServer
comment?
&&
raw
[
'commentAnchor'
]
end
def
id
raw
[
'id'
]
end
def
note
comment
[
'text'
]
end
def
comment
return
unless
comment?
def
author_username
author
[
'name'
]
@comment
||=
if
inline_comment?
PullRequestComment
.
new
(
raw_comment
)
else
Comment
.
new
(
raw_comment
)
end
def
author_email
author
[
'emailAddress'
]
end
# XXX Move this into MergeEvent
def
merge_event?
action
==
'MERGED'
end
def
commiter_user
def
commit
t
er_user
commit
.
fetch
(
'committer'
,
{})[
'displayName'
]
end
def
commiter_email
def
commit
t
er_email
commit
.
fetch
(
'committer'
,
{})[
'emailAddress'
]
end
...
...
@@ -61,12 +57,12 @@ module BitbucketServer
private
def
comment
def
raw_
comment
raw
.
fetch
(
'comment'
,
{})
end
def
author
comment
.
fetch
(
'author'
,
{})
raw_
comment
.
fetch
(
'author'
,
{})
end
# Anchor hash:
...
...
lib/bitbucket_server/representation/comment.rb
浏览文件 @
014abc9c
module
Bitbucket
module
Bitbucket
Server
module
Representation
# A general comment with the structure:
# "comment": {
# "author": {
# "active": true,
# "displayName": "root",
# "emailAddress": "stanhu+bitbucket@gitlab.com",
# "id": 1,
# "links": {
# "self": [
# {
# "href": "http://localhost:7990/users/root"
# }
# ]
# },
# "name": "root",
# "slug": "root",
# "type": "NORMAL"
# }
# }
# }
class
Comment
<
Representation
::
Base
def
author
user
[
'username'
]
def
id
raw
[
'id'
]
end
def
author_username
author
[
'username'
]
end
def
author_email
author
[
'displayName'
]
end
def
note
raw
.
fetch
(
'content'
,
{}).
fetch
(
'raw'
,
nil
)
raw
[
'text'
]
end
def
created_at
raw
[
'created_on'
]
Time
.
at
(
created_date
/
1000
)
if
created_date
.
is_a?
(
Integer
)
end
def
updated_at
raw
[
'updated_on'
]
||
raw
[
'created_on'
]
Time
.
at
(
updated_date
/
1000
)
if
created_date
.
is_a?
(
Integer
)
end
def
comments
workset
=
[
raw
[
'comments'
]].
compact
all_comments
=
[]
until
workset
.
empty?
comments
=
workset
.
pop
comments
.
each
do
|
comment
|
new_comments
=
comment
.
delete
(
'comments'
)
workset
<<
new_comments
if
new_comments
all_comments
<<
Comment
.
new
(
comment
)
end
end
all_comments
end
private
def
user
raw
.
fetch
(
'user'
,
{})
def
author
raw
.
fetch
(
'author'
,
{})
end
def
created_date
raw
[
'createdDate'
]
end
def
updated_date
raw
[
'updatedDate'
]
end
end
end
...
...
lib/bitbucket_server/representation/pull_request_comment.rb
浏览文件 @
014abc9c
module
Bitbucket
module
Bitbucket
Server
module
Representation
# An inline comment with the following structure that identifies
# the part of the diff:
#
# "commentAnchor": {
# "diffType": "EFFECTIVE",
# "fileType": "TO",
# "fromHash": "c5f4288162e2e6218180779c7f6ac1735bb56eab",
# "line": 1,
# "lineType": "ADDED",
# "orphaned": false,
# "path": "CHANGELOG.md",
# "toHash": "a4c2164330f2549f67c13f36a93884cf66e976be"
# }
class
PullRequestComment
<
Comment
def
iid
raw
[
'id
'
]
def
file_type
comment_anchor
[
'fileType
'
]
end
def
f
ile_path
inline
.
fetch
(
'path'
)
def
f
rom_sha
comment_anchor
[
'fromHash'
]
end
def
old_pos
inline
.
fetch
(
'from'
)
def
to_sha
comment_anchor
[
'toHash'
]
end
def
new_pos
inline
.
fetch
(
'to'
)
def
to?
file_type
==
'TO'
end
def
from?
file_type
==
'FROM'
end
def
parent_id
raw
.
fetch
(
'parent'
,
{}).
fetch
(
'id'
,
nil
)
def
new_pos
return
unless
to?
comment_anchor
[
'line'
]
end
def
inline?
raw
.
key?
(
'inline'
)
def
old_pos
return
unless
from?
comment_anchor
[
'line'
]
end
def
has_parent?
raw
.
key?
(
'parent
'
)
def
file_path
comment_anchor
.
fetch
(
'path
'
)
end
private
def
inline
raw
.
fetch
(
'
inline
'
,
{})
def
comment_anchor
raw
.
fetch
(
'
commentAnchor
'
,
{})
end
end
end
...
...
lib/gitlab/bitbucket_server_import/importer.rb
浏览文件 @
014abc9c
...
...
@@ -105,11 +105,11 @@ module Gitlab
inline_comments
,
pr_comments
=
comments
.
partition
(
&
:inline_comment?
)
# import_inline_comments(inline_comments, pull_request, merge_request)
import_standalone_pr_comments
(
pr_comments
,
merge_request
)
import_standalone_pr_comments
(
pr_comments
.
map
(
&
:comment
)
,
merge_request
)
end
def
import_merge_event
(
merge_request
,
merge_event
)
committer
=
merge_event
.
commiter_email
committer
=
merge_event
.
commit
t
er_email
return
unless
committer
...
...
@@ -169,6 +169,10 @@ module Gitlab
pr_comments
.
each
do
|
comment
|
begin
merge_request
.
notes
.
create!
(
pull_request_comment_attributes
(
comment
))
comment
.
comments
.
each
do
|
replies
|
merge_request
.
notes
.
create!
(
pull_request_comment_attributes
(
replies
))
end
rescue
StandardError
=>
e
errors
<<
{
type: :pull_request
,
iid:
comment
.
id
,
errors:
e
.
message
}
end
...
...
@@ -180,7 +184,6 @@ module Gitlab
end
def
pull_request_comment_attributes
(
comment
)
byebug
{
project:
project
,
note:
comment
.
note
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录