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
iv
gitlab-ce
Commits
f2fe4af1
Commit
f2fe4af1
authored
Apr 18, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set GitHub milestones to Issue/Merge Request that were imported
parent
06ec5111
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
0 deletions
+49
-0
lib/gitlab/github_import/issue_formatter.rb
lib/gitlab/github_import/issue_formatter.rb
+7
-0
lib/gitlab/github_import/pull_request_formatter.rb
lib/gitlab/github_import/pull_request_formatter.rb
+7
-0
spec/lib/gitlab/github_import/issue_formatter_spec.rb
spec/lib/gitlab/github_import/issue_formatter_spec.rb
+17
-0
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/issue_formatter.rb
View file @
f2fe4af1
...
...
@@ -5,6 +5,7 @@ module Gitlab
{
iid:
number
,
project:
project
,
milestone:
milestone
,
title:
raw_data
.
title
,
description:
description
,
state:
state
,
...
...
@@ -55,6 +56,12 @@ module Gitlab
@formatter
.
author_line
(
author
)
+
body
end
def
milestone
if
raw_data
.
milestone
.
present?
project
.
milestones
.
find_by
(
iid:
raw_data
.
milestone
.
number
)
end
end
def
state
raw_data
.
state
==
'closed'
?
'closed'
:
'opened'
end
...
...
lib/gitlab/github_import/pull_request_formatter.rb
View file @
f2fe4af1
...
...
@@ -11,6 +11,7 @@ module Gitlab
target_project:
target_project
,
target_branch:
target_branch
.
name
,
state:
state
,
milestone:
milestone
,
author_id:
author_id
,
assignee_id:
assignee_id
,
created_at:
raw_data
.
created_at
,
...
...
@@ -58,6 +59,12 @@ module Gitlab
formatter
.
author_line
(
author
)
+
body
end
def
milestone
if
raw_data
.
milestone
.
present?
project
.
milestones
.
find_by
(
iid:
raw_data
.
milestone
.
number
)
end
end
def
source_project
project
end
...
...
spec/lib/gitlab/github_import/issue_formatter_spec.rb
View file @
f2fe4af1
...
...
@@ -32,6 +32,7 @@ describe Gitlab::GithubImport::IssueFormatter, lib: true do
expected
=
{
iid:
1347
,
project:
project
,
milestone:
nil
,
title:
'Found a bug'
,
description:
"*Created by: octocat*
\n\n
I'm having a problem with this."
,
state:
'opened'
,
...
...
@@ -53,6 +54,7 @@ describe Gitlab::GithubImport::IssueFormatter, lib: true do
expected
=
{
iid:
1347
,
project:
project
,
milestone:
nil
,
title:
'Found a bug'
,
description:
"*Created by: octocat*
\n\n
I'm having a problem with this."
,
state:
'closed'
,
...
...
@@ -80,6 +82,21 @@ describe Gitlab::GithubImport::IssueFormatter, lib: true do
end
end
context
'when it has a milestone'
do
let
(
:milestone
)
{
OpenStruct
.
new
(
number:
45
)
}
let
(
:raw_data
)
{
OpenStruct
.
new
(
base_data
.
merge
(
milestone:
milestone
))
}
it
'returns nil when milestone does not exist'
do
expect
(
issue
.
attributes
.
fetch
(
:milestone
)).
to
be_nil
end
it
'returns milestone when it exists'
do
milestone
=
create
(
:milestone
,
project:
project
,
iid:
45
)
expect
(
issue
.
attributes
.
fetch
(
:milestone
)).
to
eq
milestone
end
end
context
'when author is a GitLab user'
do
let
(
:raw_data
)
{
OpenStruct
.
new
(
base_data
.
merge
(
user:
octocat
))
}
...
...
spec/lib/gitlab/github_import/pull_request_formatter_spec.rb
View file @
f2fe4af1
...
...
@@ -43,6 +43,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
target_project:
project
,
target_branch:
'master'
,
state:
'opened'
,
milestone:
nil
,
author_id:
project
.
creator_id
,
assignee_id:
nil
,
created_at:
created_at
,
...
...
@@ -67,6 +68,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
target_project:
project
,
target_branch:
'master'
,
state:
'closed'
,
milestone:
nil
,
author_id:
project
.
creator_id
,
assignee_id:
nil
,
created_at:
created_at
,
...
...
@@ -91,6 +93,7 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
target_project:
project
,
target_branch:
'master'
,
state:
'merged'
,
milestone:
nil
,
author_id:
project
.
creator_id
,
assignee_id:
nil
,
created_at:
created_at
,
...
...
@@ -128,6 +131,21 @@ describe Gitlab::GithubImport::PullRequestFormatter, lib: true do
expect
(
pull_request
.
attributes
.
fetch
(
:author_id
)).
to
eq
gl_user
.
id
end
end
context
'when it has a milestone'
do
let
(
:milestone
)
{
OpenStruct
.
new
(
number:
45
)
}
let
(
:raw_data
)
{
OpenStruct
.
new
(
base_data
.
merge
(
milestone:
milestone
))
}
it
'returns nil when milestone does not exists'
do
expect
(
pull_request
.
attributes
.
fetch
(
:milestone
)).
to
be_nil
end
it
'returns milestone when is exists'
do
milestone
=
create
(
:milestone
,
project:
project
,
iid:
45
)
expect
(
pull_request
.
attributes
.
fetch
(
:milestone
)).
to
eq
milestone
end
end
end
describe
'#number'
do
...
...
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