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
2aa4d7f1
Commit
2aa4d7f1
authored
Jul 31, 2018
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug where fallback diff notes would not have an associated position
parent
0b91a533
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+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
No files found.
lib/gitlab/bitbucket_server_import/importer.rb
View file @
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
View file @
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
...
...
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