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
c2607666
Commit
c2607666
authored
Apr 13, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import pull requests comments
parent
eb95f0e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
1 deletion
+61
-1
lib/github/import.rb
lib/github/import.rb
+61
-1
No files found.
lib/github/import.rb
View file @
c2607666
...
...
@@ -126,9 +126,69 @@ module Github
merge_request
.
assignee_id
=
user_id
(
pull_request
.
assignee
)
merge_request
.
created_at
=
pull_request
.
created_at
merge_request
.
updated_at
=
pull_request
.
updated_at
merge_request
.
save
(
validate:
false
)
merge_request
.
save
!
(
validate:
false
)
merge_request
.
merge_request_diffs
.
create
# Fetch review comments
review_comments_url
=
"/repos/
#{
owner
}
/
#{
repo
}
/pulls/
#{
pull_request
.
iid
}
/comments"
loop
do
review_comments
=
Github
::
Client
.
new
.
get
(
review_comments_url
)
ActiveRecord
::
Base
.
no_touching
do
review_comments
.
body
.
each
do
|
raw
|
begin
comment
=
Github
::
Representation
::
Comment
.
new
(
raw
)
note
=
Note
.
new
note
.
project_id
=
project
.
id
note
.
noteable
=
merge_request
note
.
note
=
comment
.
note
note
.
commit_id
=
comment
.
commit_id
note
.
line_code
=
comment
.
line_code
note
.
author_id
=
user_id
(
comment
.
author
,
project
.
creator_id
)
note
.
type
=
comment
.
type
note
.
created_at
=
comment
.
created_at
note
.
updated_at
=
comment
.
updated_at
note
.
save!
(
validate:
false
)
rescue
=>
e
error
(
:review_comment
,
comment
.
url
,
e
.
message
)
end
end
end
break
unless
review_comments_url
=
review_comments
.
rels
[
:next
]
end
# Fetch comments
comments_url
=
"/repos/
#{
owner
}
/
#{
repo
}
/issues/
#{
pull_request
.
iid
}
/comments"
loop
do
comments
=
Github
::
Client
.
new
.
get
(
comments_url
)
ActiveRecord
::
Base
.
no_touching
do
comments
.
body
.
each
do
|
raw
|
begin
comment
=
Github
::
Representation
::
Comment
.
new
(
raw
)
note
=
Note
.
new
note
.
project_id
=
project
.
id
note
.
noteable
=
merge_request
note
.
note
=
comment
.
note
note
.
author_id
=
user_id
(
comment
.
author
,
project
.
creator_id
)
note
.
created_at
=
comment
.
created_at
note
.
updated_at
=
comment
.
updated_at
note
.
save!
(
validate:
false
)
rescue
=>
e
error
(
:comment
,
comment
.
url
,
e
.
message
)
end
end
end
break
unless
comments_url
=
comments
.
rels
[
:next
]
end
rescue
=>
e
error
(
:pull_request
,
pull_request
.
url
,
e
.
message
)
ensure
...
...
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