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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
837a9065
Commit
837a9065
authored
Jan 05, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure that we're only importing local pull requests
parent
2dc74b48
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
lib/gitlab/github_import/importer.rb
lib/gitlab/github_import/importer.rb
+1
-1
lib/gitlab/github_import/pull_request_formatter.rb
lib/gitlab/github_import/pull_request_formatter.rb
+8
-0
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
+22
-0
No files found.
lib/gitlab/github_import/importer.rb
View file @
837a9065
...
...
@@ -42,7 +42,7 @@ module Gitlab
direction: :asc
).
each
do
|
raw_data
|
pull_request
=
PullRequestFormatter
.
new
(
project
,
raw_data
)
if
pull_request
.
valid?
if
!
pull_request
.
cross_project?
&&
pull_request
.
valid?
merge_request
=
MergeRequest
.
create!
(
pull_request
.
attributes
)
import_comments
(
pull_request
.
number
,
merge_request
)
import_comments_on_diff
(
pull_request
.
number
,
merge_request
)
...
...
lib/gitlab/github_import/pull_request_formatter.rb
View file @
837a9065
...
...
@@ -17,6 +17,10 @@ module Gitlab
}
end
def
cross_project?
source_repo
.
fork
==
true
end
def
number
raw_data
.
number
end
...
...
@@ -57,6 +61,10 @@ module Gitlab
project
end
def
source_repo
raw_data
.
head
.
repo
end
def
source_branch
source_project
.
repository
.
find_branch
(
raw_data
.
head
.
ref
)
end
...
...
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
View file @
837a9065
...
...
@@ -124,6 +124,28 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
end
end
describe
'#cross_project?'
do
context
'when source repo is not a fork'
do
let
(
:local_repo
)
{
OpenStruct
.
new
(
fork:
false
)
}
let
(
:source_branch
)
{
OpenStruct
.
new
(
ref:
'feature'
,
repo:
local_repo
)
}
let
(
:raw_data
)
{
OpenStruct
.
new
(
base_data
.
merge
(
head:
source_branch
))
}
it
'returns false'
do
expect
(
pull_request
.
cross_project?
).
to
eq
false
end
end
context
'when source repo is a fork'
do
let
(
:forked_repo
)
{
OpenStruct
.
new
(
fork:
true
)
}
let
(
:source_branch
)
{
OpenStruct
.
new
(
ref:
'feature'
,
repo:
forked_repo
)
}
let
(
:raw_data
)
{
OpenStruct
.
new
(
base_data
.
merge
(
head:
source_branch
))
}
it
'returns true'
do
expect
(
pull_request
.
cross_project?
).
to
eq
true
end
end
end
describe
'#number'
do
let
(
:raw_data
)
{
OpenStruct
.
new
(
base_data
.
merge
(
number:
1347
))
}
...
...
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