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
5e51fce4
Commit
5e51fce4
authored
Apr 05, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some refactoring to symbolise keys across importers and left a TODO
parent
850180aa
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
20 deletions
+23
-20
app/models/project_import_data.rb
app/models/project_import_data.rb
+6
-2
db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
...e/20160302152808_remove_wrong_import_url_from_projects.rb
+2
-2
db/schema.rb
db/schema.rb
+2
-3
lib/gitlab/bitbucket_import/client.rb
lib/gitlab/bitbucket_import/client.rb
+4
-4
lib/gitlab/bitbucket_import/project_creator.rb
lib/gitlab/bitbucket_import/project_creator.rb
+1
-1
lib/gitlab/fogbugz_import/importer.rb
lib/gitlab/fogbugz_import/importer.rb
+4
-4
lib/gitlab/fogbugz_import/project_creator.rb
lib/gitlab/fogbugz_import/project_creator.rb
+1
-1
lib/gitlab/gitlab_import/importer.rb
lib/gitlab/gitlab_import/importer.rb
+3
-3
No files found.
app/models/project_import_data.rb
View file @
5e51fce4
...
...
@@ -18,7 +18,11 @@ class ProjectImportData < ActiveRecord::Base
validates
:project
,
presence:
true
def
stringified_credentials
JSON
[
credentials
.
to_json
]
# TODO: This doesnt play well with attr_encrypted. Perhaps consider extending Marshall and specify a different Marshaller
before_validation
:symbolize_credentials
def
symbolize_credentials
return
if
credentials
.
blank?
credentials
.
deep_symbolize_keys!
end
end
db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
View file @
5e51fce4
...
...
@@ -51,9 +51,9 @@ class RemoveWrongImportUrlFromProjects < ActiveRecord::Migration
def
encrypt_data
(
data_hash
,
credentials_keys
)
new_data_hash
=
{}
credentials_keys
.
each
do
|
key
|
new_data_hash
[
key
]
=
data_hash
.
delete
(
key
)
if
data_hash
[
key
]
new_data_hash
[
key
.
to_sym
]
=
data_hash
.
delete
(
key
)
if
data_hash
[
key
]
end
new_data_hash
new_data_hash
.
deep_symbolize_keys
end
def
in_transaction
...
...
db/schema.rb
View file @
5e51fce4
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20160331
133914
)
do
ActiveRecord
::
Schema
.
define
(
version:
20160331
223143
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -44,7 +44,6 @@ ActiveRecord::Schema.define(version: 20160331133914) do
t
.
datetime
"updated_at"
t
.
string
"home_page_url"
t
.
integer
"default_branch_protection"
,
default:
2
t
.
boolean
"twitter_sharing_enabled"
,
default:
true
t
.
text
"restricted_visibility_levels"
t
.
boolean
"version_check_enabled"
,
default:
true
t
.
integer
"max_attachment_size"
,
default:
10
,
null:
false
...
...
@@ -417,9 +416,9 @@ ActiveRecord::Schema.define(version: 20160331133914) do
t
.
string
"state"
t
.
integer
"iid"
t
.
integer
"updated_by_id"
t
.
integer
"moved_to_id"
t
.
boolean
"confidential"
,
default:
false
t
.
datetime
"deleted_at"
t
.
integer
"moved_to_id"
end
add_index
"issues"
,
[
"assignee_id"
],
name:
"index_issues_on_assignee_id"
,
using: :btree
...
...
lib/gitlab/bitbucket_import/client.rb
View file @
5e51fce4
...
...
@@ -6,10 +6,10 @@ module Gitlab
attr_reader
:consumer
,
:api
def
self
.
from_project
(
project
)
credentials
=
project
.
import_data
.
stringified_credentials
if
project
.
import_data
if
defined?
(
credentials
)
&&
credentials
[
'bb_session'
]
token
=
credentials
[
'bb_session'
][
'bitbucket_access_token'
]
token_secret
=
credentials
[
'bb_session'
][
'bitbucket_access_token_secret'
]
credentials
=
project
.
import_data
if
project
.
import_data
if
credentials
&&
credentials
[
:bb_session
]
token
=
credentials
[
:bb_session
][
:bitbucket_access_token
]
token_secret
=
credentials
[
:bb_session
][
:bitbucket_access_token_secret
]
new
(
token
,
token_secret
)
else
raise
Projects
::
ImportService
::
Error
,
"Unable to find project import data credentials for project ID:
#{
@project
.
id
}
"
...
...
lib/gitlab/bitbucket_import/project_creator.rb
View file @
5e51fce4
...
...
@@ -25,7 +25,7 @@ module Gitlab
import_data
=
project
.
import_data
# merge! with a bang doesn't work here
import_data
.
credentials
=
import_data
.
credentials
.
merge
(
"bb_session"
=>
session_data
)
import_data
.
credentials
=
import_data
.
credentials
.
merge
(
bb_session:
session_data
)
import_data
.
save
project
...
...
lib/gitlab/fogbugz_import/importer.rb
View file @
5e51fce4
...
...
@@ -18,7 +18,7 @@ module Gitlab
def
execute
return
true
unless
repo
.
valid?
client
=
Gitlab
::
FogbugzImport
::
Client
.
new
(
token:
import_data_credentials
[
'fb_session'
][
'token'
],
uri:
import_data_credentials
[
'fb_session'
][
'uri'
])
client
=
Gitlab
::
FogbugzImport
::
Client
.
new
(
token:
import_data_credentials
[
:fb_session
][
:token
],
uri:
import_data_credentials
[
:fb_session
][
:uri
])
@cases
=
client
.
cases
(
@repo
.
id
.
to_i
)
@categories
=
client
.
categories
...
...
@@ -31,7 +31,7 @@ module Gitlab
private
def
import_data_credentials
@import_data_credentials
||=
project
.
import_data
.
stringified_credentials
if
project
.
import_data
@import_data_credentials
||=
project
.
import_data
if
project
.
import_data
end
def
user_map
...
...
@@ -240,8 +240,8 @@ module Gitlab
end
def
build_attachment_url
(
rel_url
)
uri
=
import_data_credentials
[
'fb_session'
][
'uri'
]
token
=
import_data_credentials
[
'fb_session'
][
'token'
]
uri
=
import_data_credentials
[
:fb_session
][
:uri
]
token
=
import_data_credentials
[
:fb_session
][
:token
]
"
#{
uri
}
/
#{
rel_url
}
&token=
#{
token
}
"
end
...
...
lib/gitlab/fogbugz_import/project_creator.rb
View file @
5e51fce4
...
...
@@ -28,7 +28,7 @@ module Gitlab
import_data
.
data
=
{
'repo'
=>
repo
.
raw_data
,
'user_map'
=>
user_map
}
# merge! with a bang doesn't work here
import_data
.
credentials
=
import_data
.
credentials
.
merge
(
'fb_session'
=>
fb_session
)
import_data
.
credentials
=
import_data
.
credentials
.
merge
(
fb_session:
fb_session
)
import_data
.
save
project
...
...
lib/gitlab/gitlab_import/importer.rb
View file @
5e51fce4
...
...
@@ -5,9 +5,9 @@ module Gitlab
def
initialize
(
project
)
@project
=
project
credentials
=
import_data
.
stringified_credentials
if
credentials
&&
credentials
[
"password"
]
@client
=
Client
.
new
(
credentials
[
"password"
])
credentials
=
import_data
if
credentials
&&
credentials
[
:password
]
@client
=
Client
.
new
(
credentials
[
:password
])
@formatter
=
Gitlab
::
ImportFormatter
.
new
else
raise
Projects
::
ImportService
::
Error
,
"Unable to find project import data credentials for project ID:
#{
@project
.
id
}
"
...
...
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