Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
4c74ed9d1cb1
Commit
06b36c00
authored
Mar 04, 2016
by
James Lopez
Browse files
some refactoring in the migration. Also fixed github import issue and updated spec
parent
1c54dd8f9413
Changes
4
Hide whitespace changes
Inline
Side-by-side
db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
View file @
4c74ed9d
...
@@ -23,11 +23,16 @@ def regex_extractor
...
@@ -23,11 +23,16 @@ def regex_extractor
end
end
def
up
def
up
projects_with_wrong_import_url
.
each
do
|
project
|
projects_with_wrong_import_url
.
each
do
|
project_id
|
sanitizer
=
ImportUrlSanitizer
.
new
(
project
.
import_urls
)
project
=
Project
.
find
(
project_id
[
"id"
])
project
.
update_columns
(
import_url:
sanitizer
.
sanitized_url
)
sanitizer
=
ImportUrlSanitizer
.
new
(
project
.
import_url
)
if
project
.
import_data
project
.
import_data
.
update_columns
(
credentials:
sanitizer
.
credentials
)
ActiveRecord
::
Base
.
transaction
do
project
.
update_columns
(
import_url:
sanitizer
.
sanitized_url
)
if
project
.
import_data
project
.
import_data
.
credentials
=
sanitizer
.
credentials
project
.
save!
end
end
end
end
end
end
end
...
...
db/schema.rb
View file @
4c74ed9d
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20160
22
215
391
8
)
do
ActiveRecord
::
Schema
.
define
(
version:
20160
30
215
280
8
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -658,6 +658,8 @@
...
@@ -658,6 +658,8 @@
create_table
"project_import_data"
,
force: :cascade
do
|
t
|
create_table
"project_import_data"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
integer
"project_id"
t
.
text
"data"
t
.
text
"data"
t
.
text
"encrypted_credentials"
t
.
text
"encrypted_credentials_iv"
end
end
create_table
"projects"
,
force: :cascade
do
|
t
|
create_table
"projects"
,
force: :cascade
do
|
t
|
...
...
lib/gitlab/github_import/project_creator.rb
View file @
4c74ed9d
...
@@ -20,13 +20,21 @@ def execute
...
@@ -20,13 +20,21 @@ def execute
visibility_level:
repo
.
private
?
Gitlab
::
VisibilityLevel
::
PRIVATE
:
Gitlab
::
VisibilityLevel
::
PUBLIC
,
visibility_level:
repo
.
private
?
Gitlab
::
VisibilityLevel
::
PRIVATE
:
Gitlab
::
VisibilityLevel
::
PUBLIC
,
import_type:
"github"
,
import_type:
"github"
,
import_source:
repo
.
full_name
,
import_source:
repo
.
full_name
,
import_url:
repo
.
clone_url
.
sub
(
"https://"
,
"https://
#{
@session_data
[
:github_access_token
]
}
@"
)
,
import_url:
repo
.
clone_url
,
wiki_enabled:
!
repo
.
has_wiki?
# If repo has wiki we'll import it later
wiki_enabled:
!
repo
.
has_wiki?
# If repo has wiki we'll import it later
).
execute
).
execute
project
.
create_import_data
(
data:
{
"github_session"
=>
session_data
}
)
create_import_data
(
project
)
project
project
end
end
private
def
create_import_data
(
project
)
project
.
create_import_data
(
credentials:
session_data
.
delete
(
:github_access_token
),
data:
{
"github_session"
=>
session_data
})
end
end
end
end
end
end
end
spec/lib/gitlab/github_import/project_creator_spec.rb
View file @
4c74ed9d
...
@@ -26,7 +26,8 @@
...
@@ -26,7 +26,8 @@
project_creator
=
Gitlab
::
GithubImport
::
ProjectCreator
.
new
(
repo
,
namespace
,
user
,
access_params
)
project_creator
=
Gitlab
::
GithubImport
::
ProjectCreator
.
new
(
repo
,
namespace
,
user
,
access_params
)
project
=
project_creator
.
execute
project
=
project_creator
.
execute
expect
(
project
.
import_url
).
to
eq
(
"https://asdffg@gitlab.com/asd/vim.git"
)
expect
(
project
.
import_url
).
to
eq
(
"https://gitlab.com/asd/vim.git"
)
expect
(
project
.
import_data
.
credentials
).
to
eq
(
"asdffg"
)
expect
(
project
.
visibility_level
).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
expect
(
project
.
visibility_level
).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
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