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
Jérome Perrin
gitlab-ce
Commits
06b36c00
Commit
06b36c00
authored
Mar 04, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some refactoring in the migration. Also fixed github import issue and updated spec
parent
cefefb2a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
9 deletions
+25
-9
db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
...e/20160302152808_remove_wrong_import_url_from_projects.rb
+10
-5
db/schema.rb
db/schema.rb
+3
-1
lib/gitlab/github_import/project_creator.rb
lib/gitlab/github_import/project_creator.rb
+10
-2
spec/lib/gitlab/github_import/project_creator_spec.rb
spec/lib/gitlab/github_import/project_creator_spec.rb
+2
-1
No files found.
db/migrate/20160302152808_remove_wrong_import_url_from_projects.rb
View file @
06b36c00
...
...
@@ -23,11 +23,16 @@ class RemoveWrongImportUrlFromProjects < ActiveRecord::Migration
end
def
up
projects_with_wrong_import_url
.
each
do
|
project
|
sanitizer
=
ImportUrlSanitizer
.
new
(
project
.
import_urls
)
projects_with_wrong_import_url
.
each
do
|
project_id
|
project
=
Project
.
find
(
project_id
[
"id"
])
sanitizer
=
ImportUrlSanitizer
.
new
(
project
.
import_url
)
ActiveRecord
::
Base
.
transaction
do
project
.
update_columns
(
import_url:
sanitizer
.
sanitized_url
)
if
project
.
import_data
project
.
import_data
.
update_columns
(
credentials:
sanitizer
.
credentials
)
project
.
import_data
.
credentials
=
sanitizer
.
credentials
project
.
save!
end
end
end
end
...
...
db/schema.rb
View file @
06b36c00
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20160
22215391
8
)
do
ActiveRecord
::
Schema
.
define
(
version:
20160
30215280
8
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -658,6 +658,8 @@ ActiveRecord::Schema.define(version: 20160222153918) do
create_table
"project_import_data"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
text
"data"
t
.
text
"encrypted_credentials"
t
.
text
"encrypted_credentials_iv"
end
create_table
"projects"
,
force: :cascade
do
|
t
|
...
...
lib/gitlab/github_import/project_creator.rb
View file @
06b36c00
...
...
@@ -20,13 +20,21 @@ module Gitlab
visibility_level:
repo
.
private
?
Gitlab
::
VisibilityLevel
::
PRIVATE
:
Gitlab
::
VisibilityLevel
::
PUBLIC
,
import_type:
"github"
,
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
).
execute
project
.
create_import_data
(
data:
{
"github_session"
=>
session_data
}
)
create_import_data
(
project
)
project
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
spec/lib/gitlab/github_import/project_creator_spec.rb
View file @
06b36c00
...
...
@@ -26,7 +26,8 @@ describe Gitlab::GithubImport::ProjectCreator, lib: true do
project_creator
=
Gitlab
::
GithubImport
::
ProjectCreator
.
new
(
repo
,
namespace
,
user
,
access_params
)
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
)
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