Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c4dbe61a
Commit
c4dbe61a
authored
Jun 28, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First iteration of importing diff notes
parent
014abc9c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
25 deletions
+26
-25
lib/bitbucket_server/representation/activity.rb
lib/bitbucket_server/representation/activity.rb
+7
-6
lib/bitbucket_server/representation/comment.rb
lib/bitbucket_server/representation/comment.rb
+10
-6
lib/gitlab/bitbucket_server_import/importer.rb
lib/gitlab/bitbucket_server_import/importer.rb
+9
-13
No files found.
lib/bitbucket_server/representation/activity.rb
View file @
c4dbe61a
...
...
@@ -10,7 +10,7 @@ module BitbucketServer
end
def
inline_comment?
comment?
&&
raw
[
'commentAnchor'
]
comment?
&&
comment_anchor
end
def
comment
...
...
@@ -18,9 +18,9 @@ module BitbucketServer
@comment
||=
if
inline_comment?
PullRequestComment
.
new
(
raw
_comment
)
PullRequestComment
.
new
(
raw
)
else
Comment
.
new
(
raw
_comment
)
Comment
.
new
(
raw
)
end
end
...
...
@@ -61,13 +61,14 @@ module BitbucketServer
raw
.
fetch
(
'comment'
,
{})
end
def
comment_anchor
raw
[
'commentAnchor'
]
end
def
author
raw_comment
.
fetch
(
'author'
,
{})
end
# Anchor hash:
# {u'toHash': u'a4c2164330f2549f67c13f36a93884cf66e976be', u'fromHash': u'c5f4288162e2e6218180779c7f6ac1735bb56eab', u'fileType': u'FROM', u'diffType': u'EFFECTIVE', u'lineType': u'CONTEXT', u'path': u'CHANGELOG.md', u'line': 3, u'orphaned': False}
def
created_date
comment
[
'createdDate'
]
end
...
...
lib/bitbucket_server/representation/comment.rb
View file @
c4dbe61a
...
...
@@ -22,7 +22,7 @@ module BitbucketServer
# }
class
Comment
<
Representation
::
Base
def
id
raw
[
'id'
]
raw
_comment
[
'id'
]
end
def
author_username
...
...
@@ -34,7 +34,7 @@ module BitbucketServer
end
def
note
raw
[
'text'
]
raw
_comment
[
'text'
]
end
def
created_at
...
...
@@ -46,7 +46,7 @@ module BitbucketServer
end
def
comments
workset
=
[
raw
[
'comments'
]].
compact
workset
=
[
raw
_comment
[
'comments'
]].
compact
all_comments
=
[]
until
workset
.
empty?
...
...
@@ -64,16 +64,20 @@ module BitbucketServer
private
def
raw_comment
raw
.
fetch
(
'comment'
,
{})
end
def
author
raw
.
fetch
(
'author'
,
{})
raw
_comment
.
fetch
(
'author'
,
{})
end
def
created_date
raw
[
'createdDate'
]
raw
_comment
[
'createdDate'
]
end
def
updated_date
raw
[
'updatedDate'
]
raw
_comment
[
'updatedDate'
]
end
end
end
...
...
lib/gitlab/bitbucket_server_import/importer.rb
View file @
c4dbe61a
...
...
@@ -104,7 +104,7 @@ module Gitlab
inline_comments
,
pr_comments
=
comments
.
partition
(
&
:inline_comment?
)
# import_inline_comments(inline_comments
, pull_request, merge_request)
import_inline_comments
(
inline_comments
.
map
(
&
:comment
)
,
pull_request
,
merge_request
)
import_standalone_pr_comments
(
pr_comments
.
map
(
&
:comment
),
merge_request
)
end
...
...
@@ -125,17 +125,13 @@ module Gitlab
def
import_inline_comments
(
inline_comments
,
pull_request
,
merge_request
)
line_code_map
=
{}
children
,
parents
=
inline_comments
.
partition
(
&
:has_parent?
)
# The BitbucketServer API returns threaded replies as parent-child
# relationships. We assume that the child can appear in any order in
# the JSON.
parents
.
each
do
|
comment
|
line_code_map
[
comment
.
iid
]
=
generate_line_code
(
comment
)
end
inline_comments
.
each
do
|
comment
|
line_code
=
generate_line_code
(
comment
)
line_code_map
[
comment
.
id
]
=
line_code
children
.
each
do
|
comment
|
line_code_map
[
comment
.
iid
]
=
line_code_map
.
fetch
(
comment
.
parent_id
,
nil
)
comment
.
comments
.
each
do
|
reply
|
line_code_map
[
reply
.
id
]
=
line_code
end
end
inline_comments
.
each
do
|
comment
|
...
...
@@ -143,12 +139,12 @@ module Gitlab
attributes
=
pull_request_comment_attributes
(
comment
)
attributes
.
merge!
(
position:
build_position
(
merge_request
,
comment
),
line_code:
line_code_map
.
fetch
(
comment
.
i
i
d
),
line_code:
line_code_map
.
fetch
(
comment
.
id
),
type:
'DiffNote'
)
merge_request
.
notes
.
create!
(
attributes
)
rescue
StandardError
=>
e
errors
<<
{
type: :pull_request
,
i
id:
comment
.
i
id
,
errors:
e
.
message
}
errors
<<
{
type: :pull_request
,
i
d:
comment
.
id
,
errors:
e
.
message
}
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment