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
Léo-Paul Géneau
gitlab-ce
Commits
288d8e66
Commit
288d8e66
authored
Apr 04, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes based on MR review
parent
ef85c510
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
...e/20160302152808_remove_wrong_import_url_from_projects.rb
+13
-14
No files found.
db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
View file @
288d8e66
...
...
@@ -17,10 +17,10 @@ class RemoveWrongImportUrlFromProjects < ActiveRecord::Migration
in_transaction
{
process_projects_with_wrong_url
}
say
(
"Migrating bitbucket credentials..."
)
in_transaction
{
process_project
(
import_type:
'bitbucket'
)
}
in_transaction
{
process_project
(
import_type:
'bitbucket'
,
credentials_keys:
[
'bb_session'
]
)
}
say
(
"Migrating fogbugz credentials..."
)
in_transaction
{
process_project
(
import_type:
'fogbugz'
,
unencrypted_data:
[
'repo'
,
'user_map
'
])
}
in_transaction
{
process_project
(
import_type:
'fogbugz'
,
credentials_keys:
[
'fb_session
'
])
}
end
...
...
@@ -33,27 +33,26 @@ class RemoveWrongImportUrlFromProjects < ActiveRecord::Migration
end
end
def
process_project
(
import_type:
,
unencrypted_data
:
[])
def
process_project
(
import_type:
,
credentials_keys
:
[])
unencrypted_import_data
(
import_type:
import_type
).
each
do
|
data
|
replace_data_credentials
(
data
,
unencrypted_data
)
replace_data_credentials
(
data
,
credentials_keys
)
end
end
def
replace_data_credentials
(
data
,
unencrypted_data
)
def
replace_data_credentials
(
data
,
credentials_keys
)
data_hash
=
JSON
.
load
(
data
[
'data'
])
if
data
[
'data'
]
if
defined?
(
data_hash
)
&&
!
data_hash
.
blank?
unencrypted_data_hash
=
encrypted_data_hash
(
data_hash
,
unencrypted_data
)
update_with_encrypted_data
(
data_hash
,
data
[
'id'
],
unencrypted_data_hash
)
unless
data_hash
.
blank?
encrypted_data_hash
=
encrypt_data
(
data_hash
,
credentials_keys
)
unencrypted_data
=
data_hash
.
empty?
?
' NULL '
:
quote
(
data_hash
.
to_json
)
update_with_encrypted_data
(
encrypted_data_hash
,
data
[
'id'
],
unencrypted_data
)
end
end
def
encrypted_data_hash
(
data_hash
,
unencrypted_data
)
return
'NULL'
if
unencrypted_data
.
empty?
def
encrypt_data
(
data_hash
,
credentials_keys
)
new_data_hash
=
{}
unencrypted_data
.
each
do
|
key
|
credentials_keys
.
each
do
|
key
|
new_data_hash
[
key
]
=
data_hash
.
delete
(
key
)
if
data_hash
[
key
]
end
quote
(
new_data_hash
.
to_json
)
end
def
in_transaction
...
...
@@ -75,10 +74,10 @@ class RemoveWrongImportUrlFromProjects < ActiveRecord::Migration
end
end
def
update_with_encrypted_data
(
data_hash
,
import_data_id
,
data_array
=
nil
)
def
update_with_encrypted_data
(
data_hash
,
import_data_id
,
unencrypted_data
=
' NULL '
)
fake_import_data
=
FakeProjectImportData
.
new
fake_import_data
.
credentials
=
data_hash
execute
(
update_import_data_sql
(
import_data_id
,
fake_import_data
,
data_array
))
execute
(
update_import_data_sql
(
import_data_id
,
fake_import_data
,
unencrypted_data
))
end
def
update_import_url
(
import_url
,
project
)
...
...
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