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
Jérome Perrin
gitlab-ce
Commits
54221b5a
Commit
54221b5a
authored
Dec 05, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix inline comment importing for 1:1 diff type
parent
32c6c9c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
lib/bitbucket/representation/pull_request_comment.rb
lib/bitbucket/representation/pull_request_comment.rb
+1
-1
lib/gitlab/bitbucket_import/importer.rb
lib/gitlab/bitbucket_import/importer.rb
+19
-7
No files found.
lib/bitbucket/representation/pull_request_comment.rb
View file @
54221b5a
...
@@ -14,7 +14,7 @@ module Bitbucket
...
@@ -14,7 +14,7 @@ module Bitbucket
end
end
def
new_pos
def
new_pos
inline
.
fetch
(
'to'
,
nil
)
||
1
inline
.
fetch
(
'to'
,
nil
)
||
old_pos
||
1
end
end
def
parent_id
def
parent_id
...
...
lib/gitlab/bitbucket_import/importer.rb
View file @
54221b5a
...
@@ -81,10 +81,10 @@ module Gitlab
...
@@ -81,10 +81,10 @@ module Gitlab
description:
description
,
description:
description
,
source_project:
project
,
source_project:
project
,
source_branch:
pull_request
.
source_branch_name
,
source_branch:
pull_request
.
source_branch_name
,
source_branch_sha:
p
ull_request
.
source_branch_sha
,
source_branch_sha:
p
roject
.
repository
.
rugged
.
lookup
(
pull_request
.
source_branch_sha
).
oid
,
target_project:
project
,
target_project:
project
,
target_branch:
pull_request
.
target_branch_name
,
target_branch:
pull_request
.
target_branch_name
,
target_branch_sha:
p
ull_request
.
target_branch_sha
,
target_branch_sha:
p
roject
.
repository
.
rugged
.
lookup
(
pull_request
.
target_branch_sha
).
oid
,
state:
pull_request
.
state
,
state:
pull_request
.
state
,
author_id:
gitlab_user_id
(
project
,
pull_request
.
author
),
author_id:
gitlab_user_id
(
project
,
pull_request
.
author
),
assignee_id:
nil
,
assignee_id:
nil
,
...
@@ -94,7 +94,7 @@ module Gitlab
...
@@ -94,7 +94,7 @@ module Gitlab
import_pull_request_comments
(
pull_request
,
merge_request
)
if
merge_request
.
persisted?
import_pull_request_comments
(
pull_request
,
merge_request
)
if
merge_request
.
persisted?
rescue
ActiveRecord
::
RecordInvalid
rescue
ActiveRecord
::
RecordInvalid
Rails
.
log
.
error
(
"Bitbucket importer ERROR in
#{
project
.
path_with_namespace
}
: Invalid pull request
#{
e
.
message
}
"
)
Rails
.
log
ger
.
error
(
"Bitbucket importer ERROR in
#{
project
.
path_with_namespace
}
: Invalid pull request
#{
e
.
message
}
"
)
end
end
end
end
end
end
...
@@ -128,24 +128,36 @@ module Gitlab
...
@@ -128,24 +128,36 @@ module Gitlab
begin
begin
attributes
=
pull_request_comment_attributes
(
comment
)
attributes
=
pull_request_comment_attributes
(
comment
)
attributes
.
merge!
(
attributes
.
merge!
(
commit_id:
pull_request
.
source_branch_sha
,
position:
build_position
(
merge_request
,
comment
)
,
line_code:
line_code_map
.
fetch
(
comment
.
iid
),
line_code:
line_code_map
.
fetch
(
comment
.
iid
),
type:
'
Legacy
DiffNote'
)
type:
'DiffNote'
)
merge_request
.
notes
.
create!
(
attributes
)
merge_request
.
notes
.
create!
(
attributes
)
rescue
ActiveRecord
::
RecordInvalid
=>
e
rescue
ActiveRecord
::
RecordInvalid
=>
e
Rails
.
log
.
error
(
"Bitbucket importer ERROR in
#{
project
.
path_with_namespace
}
: Invalid pull request comment
#{
e
.
message
}
"
)
Rails
.
log
ger
.
error
(
"Bitbucket importer ERROR in
#{
project
.
path_with_namespace
}
: Invalid pull request comment
#{
e
.
message
}
"
)
nil
nil
end
end
end
end
end
end
def
build_position
(
merge_request
,
pr_comment
)
params
=
{
diff_refs:
merge_request
.
diff_refs
,
old_path:
pr_comment
.
file_path
,
new_path:
pr_comment
.
file_path
,
old_line:
pr_comment
.
old_pos
,
new_line:
pr_comment
.
new_pos
}
Gitlab
::
Diff
::
Position
.
new
(
params
)
end
def
import_standalone_pr_comments
(
pr_comments
,
merge_request
)
def
import_standalone_pr_comments
(
pr_comments
,
merge_request
)
pr_comments
.
each
do
|
comment
|
pr_comments
.
each
do
|
comment
|
begin
begin
merge_request
.
notes
.
create!
(
pull_request_comment_attributes
(
comment
))
merge_request
.
notes
.
create!
(
pull_request_comment_attributes
(
comment
))
rescue
ActiveRecord
::
RecordInvalid
=>
e
rescue
ActiveRecord
::
RecordInvalid
=>
e
Rails
.
log
.
error
(
"Bitbucket importer ERROR in
#{
project
.
path_with_namespace
}
: Invalid standalone pull request comment
#{
e
.
message
}
"
)
Rails
.
log
ger
.
error
(
"Bitbucket importer ERROR in
#{
project
.
path_with_namespace
}
: Invalid standalone pull request comment
#{
e
.
message
}
"
)
nil
nil
end
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