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
Léo-Paul Géneau
gitlab-ce
Commits
d72b2581
Commit
d72b2581
authored
Dec 21, 2015
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Doesn't import GitHub PR where branches were no longer available
parent
f19bf0ea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
38 deletions
+44
-38
lib/gitlab/github_import/importer.rb
lib/gitlab/github_import/importer.rb
+44
-38
No files found.
lib/gitlab/github_import/importer.rb
View file @
d72b2581
...
...
@@ -52,19 +52,18 @@ module Gitlab
client
.
pull_requests
(
project
.
import_source
,
state: :all
,
sort: :created
,
direction: :asc
).
each
do
|
pull_request
|
body
=
@formatter
.
author_line
(
pull_request
.
user
.
login
)
body
+=
pull_request
.
body
||
""
source_branch
=
pull_request
.
head
.
ref
target_branch
=
pull_request
.
base
.
ref
source_branch
=
find_branch
(
pull_request
.
head
.
ref
)
target_branch
=
find_branch
(
pull_request
.
base
.
ref
)
if
source_branch
&&
target_branch
# Pull Request
merge_request
=
MergeRequest
.
create!
(
title:
pull_request
.
title
,
description:
body
,
description:
format_body
(
pull_request
.
user
.
login
,
pull_request
.
body
)
,
source_project:
project
,
source_branch:
source_branch
,
source_branch:
source_branch
.
name
,
target_project:
project
,
target_branch:
target_branch
,
target_branch:
target_branch
.
name
,
state:
merge_request_state
(
pull_request
),
author_id:
gl_author_id
(
project
,
pull_request
.
user
.
id
),
assignee_id:
gl_user_id
(
pull_request
.
assignee
.
try
(
:id
)),
...
...
@@ -72,6 +71,7 @@ module Gitlab
updated_at:
pull_request
.
updated_at
)
# Comments on Pull Request
client
.
issue_comments
(
project
.
import_source
,
pull_request
.
number
).
each
do
|
c
|
merge_request
.
notes
.
create!
(
project:
project
,
...
...
@@ -82,6 +82,7 @@ module Gitlab
)
end
# Comments on Pull Request diff
client
.
pull_request_comments
(
project
.
import_source
,
pull_request
.
number
).
each
do
|
c
|
merge_request
.
notes
.
create!
(
project:
project
,
...
...
@@ -95,6 +96,11 @@ module Gitlab
end
end
end
end
def
find_branch
(
name
)
project
.
repository
.
find_branch
(
name
)
end
def
format_body
(
author
,
body
)
@formatter
.
author_line
(
author
)
+
(
body
||
""
)
...
...
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