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
ce35dcbc
Commit
ce35dcbc
authored
Mar 08, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor some code
parent
4a0cf269
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
lib/gitlab/github_import/pull_request_formatter.rb
lib/gitlab/github_import/pull_request_formatter.rb
+6
-2
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
+18
-0
No files found.
lib/gitlab/github_import/pull_request_formatter.rb
View file @
ce35dcbc
...
@@ -38,8 +38,8 @@ module Gitlab
...
@@ -38,8 +38,8 @@ module Gitlab
def
source_branch_name
def
source_branch_name
@source_branch_name
||=
begin
@source_branch_name
||=
begin
if
source_branch
.
repo
.
id
!=
target_branch
.
repo
.
id
if
cross_project?
"pull/
#{
number
}
/
#{
source_branch
.
repo
.
full_name
}
/
#{
source_branch_ref
}
"
"pull/
#{
number
}
/
#{
source_branch
_
repo
.
full_name
}
/
#{
source_branch_ref
}
"
else
else
source_branch_exists?
?
source_branch_ref
:
"pull/
#{
number
}
/
#{
source_branch_ref
}
"
source_branch_exists?
?
source_branch_ref
:
"pull/
#{
number
}
/
#{
source_branch_ref
}
"
end
end
...
@@ -56,6 +56,10 @@ module Gitlab
...
@@ -56,6 +56,10 @@ module Gitlab
end
end
end
end
def
cross_project?
source_branch
.
repo
.
id
!=
target_branch
.
repo
.
id
end
private
private
def
state
def
state
...
...
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
View file @
ce35dcbc
...
@@ -281,6 +281,24 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
...
@@ -281,6 +281,24 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
end
end
end
end
describe
'#cross_project?'
do
context
'when source and target repositories are different'
do
let
(
:raw_data
)
{
double
(
base_data
.
merge
(
head:
forked_branch
))
}
it
'returns true'
do
expect
(
pull_request
.
cross_project?
).
to
eq
true
end
end
context
'when source and target repositories are the same'
do
let
(
:raw_data
)
{
double
(
base_data
.
merge
(
head:
source_branch
))
}
it
'returns false'
do
expect
(
pull_request
.
cross_project?
).
to
eq
false
end
end
end
describe
'#url'
do
describe
'#url'
do
let
(
:raw_data
)
{
double
(
base_data
)
}
let
(
:raw_data
)
{
double
(
base_data
)
}
...
...
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