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
9d00bb08
Commit
9d00bb08
authored
Apr 14, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import Google Code issue assignee when mapped.
parent
2f797a14
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
3 deletions
+26
-3
lib/gitlab/google_code_import/importer.rb
lib/gitlab/google_code_import/importer.rb
+14
-0
spec/fixtures/GoogleCodeProjectHosting.json
spec/fixtures/GoogleCodeProjectHosting.json
+5
-0
spec/lib/gitlab/google_code_import/importer_spec.rb
spec/lib/gitlab/google_code_import/importer_spec.rb
+7
-3
No files found.
lib/gitlab/google_code_import/importer.rb
View file @
9d00bb08
...
@@ -99,10 +99,24 @@ module Gitlab
...
@@ -99,10 +99,24 @@ module Gitlab
end
end
labels
<<
nice_status_name
(
raw_issue
[
"status"
])
labels
<<
nice_status_name
(
raw_issue
[
"status"
])
assignee_id
=
nil
if
raw_issue
.
has_key?
(
"owner"
)
username
=
user_map
[
raw_issue
[
"owner"
][
"name"
]]
if
username
.
start_with?
(
"@"
)
username
=
username
[
1
..-
1
]
if
user
=
User
.
find_by
(
username:
username
)
assignee_id
=
user
.
id
end
end
end
issue
=
project
.
issues
.
create!
(
issue
=
project
.
issues
.
create!
(
title:
raw_issue
[
"title"
],
title:
raw_issue
[
"title"
],
description:
body
,
description:
body
,
author_id:
project
.
creator_id
,
author_id:
project
.
creator_id
,
assignee_id:
assignee_id
,
state:
raw_issue
[
"state"
]
==
"closed"
?
"closed"
:
"opened"
state:
raw_issue
[
"state"
]
==
"closed"
?
"closed"
:
"opened"
)
)
issue
.
add_labels_by_names
(
labels
)
issue
.
add_labels_by_names
(
labels
)
...
...
spec/fixtures/GoogleCodeProjectHosting.json
View file @
9d00bb08
...
@@ -344,6 +344,11 @@
...
@@ -344,6 +344,11 @@
"name"
:
"schattenpr..."
,
"name"
:
"schattenpr..."
,
"htmlLink"
:
"https://code.google.com/u/106498139506637530000/"
"htmlLink"
:
"https://code.google.com/u/106498139506637530000/"
},
},
"owner"
:
{
"kind"
:
"projecthosting#issuePerson"
,
"name"
:
"thilo..."
,
"htmlLink"
:
"https://code.google.com/u/104224918623172014000/"
},
"updated"
:
"2009-11-18T05:14:58.000Z"
,
"updated"
:
"2009-11-18T05:14:58.000Z"
,
"published"
:
"2009-11-18T00:20:19.000Z"
,
"published"
:
"2009-11-18T00:20:19.000Z"
,
"closed"
:
"2009-11-18T05:14:58.000Z"
,
"closed"
:
"2009-11-18T05:14:58.000Z"
,
...
...
spec/lib/gitlab/google_code_import/importer_spec.rb
View file @
9d00bb08
require
"spec_helper"
require
"spec_helper"
describe
Gitlab
::
GoogleCodeImport
::
Importer
do
describe
Gitlab
::
GoogleCodeImport
::
Importer
do
let
(
:mapped_user
)
{
create
(
:user
,
username:
"thilo123"
)
}
let
(
:raw_data
)
{
JSON
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
"spec/fixtures/GoogleCodeProjectHosting.json"
)))
}
let
(
:raw_data
)
{
JSON
.
parse
(
File
.
read
(
Rails
.
root
.
join
(
"spec/fixtures/GoogleCodeProjectHosting.json"
)))
}
let
(
:client
)
{
Gitlab
::
GoogleCodeImport
::
Client
.
new
(
raw_data
)
}
let
(
:client
)
{
Gitlab
::
GoogleCodeImport
::
Client
.
new
(
raw_data
)
}
let
(
:import_data
)
{
let
(
:import_data
)
{
{
{
"repo"
=>
client
.
repo
(
"tint2"
).
raw_data
,
"repo"
=>
client
.
repo
(
"tint2"
).
raw_data
,
"user_map"
=>
{
"user_map"
=>
{
"thilo..."
=>
"@
thilo123
"
"thilo..."
=>
"@
#{
mapped_user
.
username
}
"
}
}
}
}
}
}
let
(
:project
)
{
create
(
:project
,
import_data:
import_data
)
}
let
(
:project
)
{
create
(
:project
,
import_data:
import_data
)
}
subject
{
described_class
.
new
(
project
)
}
subject
{
described_class
.
new
(
project
)
}
describe
"#execute"
do
describe
"#execute"
do
it
"imports status labels"
do
it
"imports status labels"
do
subject
.
execute
subject
.
execute
...
@@ -43,6 +45,8 @@ describe Gitlab::GoogleCodeImport::Importer do
...
@@ -43,6 +45,8 @@ describe Gitlab::GoogleCodeImport::Importer do
issue
=
project
.
issues
.
first
issue
=
project
.
issues
.
first
expect
(
issue
).
to_not
be_nil
expect
(
issue
).
to_not
be_nil
expect
(
issue
.
iid
).
to
eq
(
169
)
expect
(
issue
.
iid
).
to
eq
(
169
)
expect
(
issue
.
author
).
to
eq
(
project
.
creator
)
expect
(
issue
.
assignee
).
to
eq
(
mapped_user
)
expect
(
issue
.
state
).
to
eq
(
"closed"
)
expect
(
issue
.
state
).
to
eq
(
"closed"
)
expect
(
issue
.
label_names
).
to
include
(
"Priority: Medium"
)
expect
(
issue
.
label_names
).
to
include
(
"Priority: Medium"
)
expect
(
issue
.
label_names
).
to
include
(
"Status: Fixed"
)
expect
(
issue
.
label_names
).
to
include
(
"Status: Fixed"
)
...
@@ -65,7 +69,7 @@ describe Gitlab::GoogleCodeImport::Importer do
...
@@ -65,7 +69,7 @@ describe Gitlab::GoogleCodeImport::Importer do
note
=
project
.
issues
.
first
.
notes
.
first
note
=
project
.
issues
.
first
.
notes
.
first
expect
(
note
).
to_not
be_nil
expect
(
note
).
to_not
be_nil
expect
(
note
.
note
).
to
include
(
"Comment 1"
)
expect
(
note
.
note
).
to
include
(
"Comment 1"
)
expect
(
note
.
note
).
to
include
(
"@
thilo123
"
)
expect
(
note
.
note
).
to
include
(
"@
#{
mapped_user
.
username
}
"
)
expect
(
note
.
note
).
to
include
(
"November 18, 2009 05:14"
)
expect
(
note
.
note
).
to
include
(
"November 18, 2009 05:14"
)
expect
(
note
.
note
).
to
include
(
"applied, thanks."
)
expect
(
note
.
note
).
to
include
(
"applied, thanks."
)
expect
(
note
.
note
).
to
include
(
"Status: Fixed"
)
expect
(
note
.
note
).
to
include
(
"Status: Fixed"
)
...
...
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