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
06ec5111
Commit
06ec5111
authored
Apr 18, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import milestones from GitHub
parent
17b60d68
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
142 additions
and
1 deletion
+142
-1
lib/gitlab/github_import/importer.rb
lib/gitlab/github_import/importer.rb
+12
-1
lib/gitlab/github_import/milestone_formatter.rb
lib/gitlab/github_import/milestone_formatter.rb
+48
-0
spec/lib/gitlab/github_import/milestone_formatter_spec.rb
spec/lib/gitlab/github_import/milestone_formatter_spec.rb
+82
-0
No files found.
lib/gitlab/github_import/importer.rb
View file @
06ec5111
...
...
@@ -16,7 +16,8 @@ module Gitlab
end
def
execute
import_labels
&&
import_issues
&&
import_pull_requests
&&
import_wiki
import_labels
&&
import_milestones
&&
import_issues
&&
import_pull_requests
&&
import_wiki
end
private
...
...
@@ -35,6 +36,16 @@ module Gitlab
raise
Projects
::
ImportService
::
Error
,
e
.
message
end
def
import_milestones
client
.
list_milestones
(
project
.
import_source
,
state: :all
).
each
do
|
raw_data
|
Milestone
.
create!
(
MilestoneFormatter
.
new
(
project
,
raw_data
).
attributes
)
end
true
rescue
ActiveRecord
::
RecordInvalid
=>
e
raise
Projects
::
ImportService
::
Error
,
e
.
message
end
def
import_issues
client
.
list_issues
(
project
.
import_source
,
state: :all
,
sort: :created
,
...
...
lib/gitlab/github_import/milestone_formatter.rb
0 → 100644
View file @
06ec5111
module
Gitlab
module
GithubImport
class
MilestoneFormatter
<
BaseFormatter
def
attributes
{
iid:
number
,
project:
project
,
title:
title
,
description:
description
,
due_date:
due_date
,
state:
state
,
created_at:
created_at
,
updated_at:
updated_at
}
end
private
def
number
raw_data
.
number
end
def
title
raw_data
.
title
end
def
description
raw_data
.
description
end
def
due_date
raw_data
.
due_on
end
def
state
raw_data
.
state
==
'closed'
?
'closed'
:
'active'
end
def
created_at
raw_data
.
created_at
end
def
updated_at
state
==
'closed'
?
raw_data
.
closed_at
:
raw_data
.
updated_at
end
end
end
end
spec/lib/gitlab/github_import/milestone_formatter_spec.rb
0 → 100644
View file @
06ec5111
require
'spec_helper'
describe
Gitlab
::
GithubImport
::
MilestoneFormatter
,
lib:
true
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:created_at
)
{
DateTime
.
strptime
(
'2011-01-26T19:01:12Z'
)
}
let
(
:updated_at
)
{
DateTime
.
strptime
(
'2011-01-27T19:01:12Z'
)
}
let
(
:base_data
)
do
{
number:
1347
,
state:
'open'
,
title:
'1.0'
,
description:
'Version 1.0'
,
due_on:
nil
,
created_at:
created_at
,
updated_at:
updated_at
,
closed_at:
nil
}
end
subject
(
:formatter
)
{
described_class
.
new
(
project
,
raw_data
)}
describe
'#attributes'
do
context
'when milestone is open'
do
let
(
:raw_data
)
{
double
(
base_data
.
merge
(
state:
'open'
))
}
it
'returns formatted attributes'
do
expected
=
{
iid:
1347
,
project:
project
,
title:
'1.0'
,
description:
'Version 1.0'
,
state:
'active'
,
due_date:
nil
,
created_at:
created_at
,
updated_at:
updated_at
}
expect
(
formatter
.
attributes
).
to
eq
(
expected
)
end
end
context
'when milestone is closed'
do
let
(
:closed_at
)
{
DateTime
.
strptime
(
'2011-01-28T19:01:12Z'
)
}
let
(
:raw_data
)
{
double
(
base_data
.
merge
(
state:
'closed'
,
closed_at:
closed_at
))
}
it
'returns formatted attributes'
do
expected
=
{
iid:
1347
,
project:
project
,
title:
'1.0'
,
description:
'Version 1.0'
,
state:
'closed'
,
due_date:
nil
,
created_at:
created_at
,
updated_at:
closed_at
}
expect
(
formatter
.
attributes
).
to
eq
(
expected
)
end
end
context
'when milestone has a due date'
do
let
(
:due_date
)
{
DateTime
.
strptime
(
'2011-01-28T19:01:12Z'
)
}
let
(
:raw_data
)
{
double
(
base_data
.
merge
(
due_on:
due_date
))
}
it
'returns formatted attributes'
do
expected
=
{
iid:
1347
,
project:
project
,
title:
'1.0'
,
description:
'Version 1.0'
,
state:
'active'
,
due_date:
due_date
,
created_at:
created_at
,
updated_at:
updated_at
}
expect
(
formatter
.
attributes
).
to
eq
(
expected
)
end
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