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
Tatuya Kamada
gitlab-ce
Commits
9b53cb6c
Commit
9b53cb6c
authored
Mar 07, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix GitHub Import for open PRs from a fork
parent
c4ba6ea6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletion
+37
-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
+12
-0
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
+24
-0
No files found.
lib/gitlab/github_import/importer.rb
View file @
9b53cb6c
...
...
@@ -148,7 +148,7 @@ module Gitlab
rescue
=>
e
errors
<<
{
type: :pull_request
,
url:
Gitlab
::
UrlSanitizer
.
sanitize
(
gh_pull_request
.
url
),
errors:
e
.
message
}
ensure
clean_up_restored_branches
(
gh_pull_request
)
clean_up_restored_branches
(
gh_pull_request
)
unless
gh_pull_request
.
opened?
end
end
end
...
...
lib/gitlab/github_import/pull_request_formatter.rb
View file @
9b53cb6c
...
...
@@ -60,6 +60,18 @@ module Gitlab
source_branch
.
repo
.
id
!=
target_branch
.
repo
.
id
end
def
opened?
state
==
'opened'
end
def
closed?
state
==
'closed'
end
def
merged?
state
==
'merged'
end
private
def
state
...
...
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
View file @
9b53cb6c
...
...
@@ -306,4 +306,28 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
expect
(
pull_request
.
url
).
to
eq
'https://api.github.com/repos/octocat/Hello-World/pulls/1347'
end
end
describe
'#opened?'
do
let
(
:raw_data
)
{
double
(
base_data
.
merge
(
state:
'open'
))
}
it
'returns true when state is "open"'
do
expect
(
pull_request
.
opened?
).
to
be_truthy
end
end
describe
'#closed?'
do
let
(
:raw_data
)
{
double
(
base_data
.
merge
(
state:
'closed'
))
}
it
'returns true when state is "closed"'
do
expect
(
pull_request
.
closed?
).
to
be_truthy
end
end
describe
'#merged?'
do
let
(
:raw_data
)
{
double
(
base_data
.
merge
(
state:
'closed'
,
merged_at:
Date
.
today
))
}
it
'returns true when state is "closed" and merged_at is set'
do
expect
(
pull_request
.
merged?
).
to
be_truthy
end
end
end
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