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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
f4bdbecf
Commit
f4bdbecf
authored
Jan 20, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cross projects detection when importing GitHub pull requests
parent
714f95b2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
lib/gitlab/github_import/pull_request_formatter.rb
lib/gitlab/github_import/pull_request_formatter.rb
+5
-1
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
+18
-9
No files found.
lib/gitlab/github_import/pull_request_formatter.rb
View file @
f4bdbecf
...
@@ -18,7 +18,7 @@ module Gitlab
...
@@ -18,7 +18,7 @@ module Gitlab
end
end
def
cross_project?
def
cross_project?
source_repo
.
fork
==
true
source_repo
.
id
!=
target_repo
.
id
end
end
def
number
def
number
...
@@ -73,6 +73,10 @@ module Gitlab
...
@@ -73,6 +73,10 @@ module Gitlab
project
project
end
end
def
target_repo
raw_data
.
base
.
repo
end
def
target_branch
def
target_branch
target_project
.
repository
.
find_branch
(
raw_data
.
base
.
ref
)
target_project
.
repository
.
find_branch
(
raw_data
.
base
.
ref
)
end
end
...
...
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
View file @
f4bdbecf
...
@@ -2,8 +2,11 @@ require 'spec_helper'
...
@@ -2,8 +2,11 @@ require 'spec_helper'
describe
Gitlab
::
GithubImport
::
PullRequestFormatter
,
lib:
true
do
describe
Gitlab
::
GithubImport
::
PullRequestFormatter
,
lib:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:source_branch
)
{
OpenStruct
.
new
(
ref:
'feature'
)
}
let
(
:repository
)
{
OpenStruct
.
new
(
id:
1
,
fork:
false
)
}
let
(
:target_branch
)
{
OpenStruct
.
new
(
ref:
'master'
)
}
let
(
:source_repo
)
{
repository
}
let
(
:source_branch
)
{
OpenStruct
.
new
(
ref:
'feature'
,
repo:
source_repo
)
}
let
(
:target_repo
)
{
repository
}
let
(
:target_branch
)
{
OpenStruct
.
new
(
ref:
'master'
,
repo:
target_repo
)
}
let
(
:octocat
)
{
OpenStruct
.
new
(
id:
123456
,
login:
'octocat'
)
}
let
(
:octocat
)
{
OpenStruct
.
new
(
id:
123456
,
login:
'octocat'
)
}
let
(
:created_at
)
{
DateTime
.
strptime
(
'2011-01-26T19:01:12Z'
)
}
let
(
:created_at
)
{
DateTime
.
strptime
(
'2011-01-26T19:01:12Z'
)
}
let
(
:updated_at
)
{
DateTime
.
strptime
(
'2011-01-27T19:01:12Z'
)
}
let
(
:updated_at
)
{
DateTime
.
strptime
(
'2011-01-27T19:01:12Z'
)
}
...
@@ -125,10 +128,8 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
...
@@ -125,10 +128,8 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
end
end
describe
'#cross_project?'
do
describe
'#cross_project?'
do
context
'when source repo is not a fork'
do
context
'when source, and target repositories are the same'
do
let
(
:local_repo
)
{
OpenStruct
.
new
(
fork:
false
)
}
let
(
:raw_data
)
{
OpenStruct
.
new
(
base_data
)
}
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
it
'returns false'
do
expect
(
pull_request
.
cross_project?
).
to
eq
false
expect
(
pull_request
.
cross_project?
).
to
eq
false
...
@@ -136,9 +137,17 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
...
@@ -136,9 +137,17 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
end
end
context
'when source repo is a fork'
do
context
'when source repo is a fork'
do
let
(
:forked_repo
)
{
OpenStruct
.
new
(
fork:
true
)
}
let
(
:source_repo
)
{
OpenStruct
.
new
(
id:
2
,
fork:
true
)
}
let
(
:source_branch
)
{
OpenStruct
.
new
(
ref:
'feature'
,
repo:
forked_repo
)
}
let
(
:raw_data
)
{
OpenStruct
.
new
(
base_data
)
}
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
context
'when target repo is a fork'
do
let
(
:target_repo
)
{
OpenStruct
.
new
(
id:
2
,
fork:
true
)
}
let
(
:raw_data
)
{
OpenStruct
.
new
(
base_data
)
}
it
'returns true'
do
it
'returns true'
do
expect
(
pull_request
.
cross_project?
).
to
eq
true
expect
(
pull_request
.
cross_project?
).
to
eq
true
...
...
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