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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
ee5f8f28
Commit
ee5f8f28
authored
Jun 28, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix generation of diff line positions
parent
5817c670
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
5 deletions
+42
-5
lib/bitbucket_server/representation/pull_request_comment.rb
lib/bitbucket_server/representation/pull_request_comment.rb
+41
-4
lib/gitlab/bitbucket_server_import/importer.rb
lib/gitlab/bitbucket_server_import/importer.rb
+1
-1
No files found.
lib/bitbucket_server/representation/pull_request_comment.rb
View file @
ee5f8f28
...
...
@@ -34,16 +34,26 @@ module BitbucketServer
file_type
==
'FROM'
end
def
added?
line_type
==
'ADDED'
end
def
removed?
line_type
==
'REMOVED'
end
def
new_pos
return
unless
to?
return
if
removed?
return
unless
line_position
comment_anchor
[
'line'
]
line_position
[
1
]
end
def
old_pos
return
unless
from?
return
if
added?
return
unless
line_position
comment_anchor
[
'line'
]
line_position
[
0
]
end
def
file_path
...
...
@@ -52,9 +62,36 @@ module BitbucketServer
private
def
line_type
comment_anchor
[
'lineType'
]
end
def
line_position
@line_position
||=
diff_hunks
.
each
do
|
hunk
|
segments
=
hunk
.
fetch
(
'segments'
,
[])
segments
.
each
do
|
segment
|
lines
=
segment
.
fetch
(
'lines'
,
[])
lines
.
each
do
|
line
|
if
line
[
'commentIds'
]
&
.
include?
(
id
)
return
[
line
[
'source'
],
line
[
'destination'
]]
end
end
end
end
end
def
comment_anchor
raw
.
fetch
(
'commentAnchor'
,
{})
end
def
diff
raw
.
fetch
(
'diff'
,
{})
end
def
diff_hunks
diff
.
fetch
(
'hunks'
,
[])
end
end
end
end
lib/gitlab/bitbucket_server_import/importer.rb
View file @
ee5f8f28
...
...
@@ -143,7 +143,7 @@ module Gitlab
attributes
=
pull_request_comment_attributes
(
reply
)
attributes
.
merge!
(
position:
build_position
(
merge_request
,
comment
),
line_code:
line_code_map
.
fetch
(
reply
.
id
)
line_code:
line_code_map
.
fetch
(
reply
.
id
)
,
discussion_id:
parent
.
discussion_id
,
type:
'DiffNote'
)
merge_request
.
notes
.
create!
(
attributes
)
...
...
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