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
Tatuya Kamada
gitlab-ce
Commits
7f853e22
Commit
7f853e22
authored
Aug 16, 2016
by
Ruben Davila
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'dev/master'
parents
07d57594
9ef8de2f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
81 additions
and
51 deletions
+81
-51
CHANGELOG
CHANGELOG
+3
-0
app/controllers/import/gitlab_projects_controller.rb
app/controllers/import/gitlab_projects_controller.rb
+5
-0
app/views/projects/new.html.haml
app/views/projects/new.html.haml
+1
-1
doc/user/project/settings/import_export.md
doc/user/project/settings/import_export.md
+1
-2
features/dashboard/new_project.feature
features/dashboard/new_project.feature
+1
-1
features/steps/dashboard/new_project.rb
features/steps/dashboard/new_project.rb
+1
-2
lib/gitlab/import_export/json_hash_builder.rb
lib/gitlab/import_export/json_hash_builder.rb
+3
-6
spec/features/projects/import_export/import_file_spec.rb
spec/features/projects/import_export/import_file_spec.rb
+60
-38
spec/lib/gitlab/import_export/reader_spec.rb
spec/lib/gitlab/import_export/reader_spec.rb
+2
-1
spec/support/import_export/import_export.yml
spec/support/import_export/import_export.yml
+4
-0
No files found.
CHANGELOG
View file @
7f853e22
...
...
@@ -117,6 +117,9 @@ v 8.11.0 (unreleased)
- Speed up todos queries by limiting the projects set we join with
- Ensure file editing in UI does not overwrite commited changes without warning user
v 8.10.6 (unreleased)
- Fix import/export configuration missing some included attributes
v 8.10.5
- Add a data migration to fix some missing timestamps in the members table. !5670
- Revert the "Defend against 'Host' header injection" change in the source NGINX templates. !5706
...
...
app/controllers/import/gitlab_projects_controller.rb
View file @
7f853e22
class
Import::GitlabProjectsController
<
Import
::
BaseController
before_action
:verify_gitlab_project_import_enabled
before_action
:authenticate_admin!
def
new
@namespace_id
=
project_params
[
:namespace_id
]
...
...
@@ -47,4 +48,8 @@ class Import::GitlabProjectsController < Import::BaseController
:path
,
:namespace_id
,
:file
)
end
def
authenticate_admin!
render_404
unless
current_user
.
is_admin?
end
end
app/views/projects/new.html.haml
View file @
7f853e22
...
...
@@ -77,7 +77,7 @@
=
link_to
"#"
,
class:
'btn js-toggle-button import_git'
do
=
icon
(
'git'
,
text:
'Repo by URL'
)
%div
{
class:
'import_gitlab_project'
}
-
if
gitlab_project_import_enabled?
-
if
gitlab_project_import_enabled?
&&
current_user
.
is_admin?
=
link_to
new_import_gitlab_project_path
,
class:
'btn btn_import_gitlab_project project-submit'
do
=
icon
(
'gitlab'
,
text:
'GitLab export'
)
...
...
doc/user/project/settings/import_export.md
View file @
7f853e22
...
...
@@ -7,8 +7,7 @@
> than that of the exporter.
> - For existing installations, the project import option has to be enabled in
> application settings (`/admin/application_settings`) under 'Import sources'.
> Ask your administrator if you don't see the **GitLab export** button when
> creating a new project.
> You will have to be an administrator to enable and use the import functionality.
> - You can find some useful raketasks if you are an administrator in the
> [import_export](../../../administration/raketasks/project_import_export.md)
> raketask.
...
...
features/dashboard/new_project.feature
View file @
7f853e22
...
...
@@ -9,7 +9,7 @@ Background:
@javascript
Scenario
:
I
should see New Projects page
Then
I see
"New Project"
page
Then
I see all possible import optios
Then
I see all possible import optio
n
s
@javascript
Scenario
:
I
should see instructions on how to import from Git URL
...
...
features/steps/dashboard/new_project.rb
View file @
7f853e22
...
...
@@ -14,14 +14,13 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps
expect
(
page
).
to
have_content
(
'Project name'
)
end
step
'I see all possible import optios'
do
step
'I see all possible import optio
n
s'
do
expect
(
page
).
to
have_link
(
'GitHub'
)
expect
(
page
).
to
have_link
(
'Bitbucket'
)
expect
(
page
).
to
have_link
(
'GitLab.com'
)
expect
(
page
).
to
have_link
(
'Gitorious.org'
)
expect
(
page
).
to
have_link
(
'Google Code'
)
expect
(
page
).
to
have_link
(
'Repo by URL'
)
expect
(
page
).
to
have_link
(
'GitLab export'
)
end
step
'I click on "Import project from GitHub"'
do
...
...
lib/gitlab/import_export/json_hash_builder.rb
View file @
7f853e22
...
...
@@ -57,19 +57,16 @@ module Gitlab
# +value+ existing model to be included in the hash
# +json_config_hash+ the original hash containing the root model
def
create_model_value
(
current_key
,
value
,
json_config_hash
)
parsed_hash
=
{
include:
value
}
parse_hash
(
value
,
parsed_hash
)
json_config_hash
[
current_key
]
=
parsed_hash
json_config_hash
[
current_key
]
=
parse_hash
(
value
)
||
{
include:
value
}
end
# Calls attributes finder to parse the hash and add any attributes to it
#
# +value+ existing model to be included in the hash
# +parsed_hash+ the original hash
def
parse_hash
(
value
,
parsed_hash
)
def
parse_hash
(
value
)
@attributes_finder
.
parse
(
value
)
do
|
hash
|
parsed_hash
=
{
include:
hash_or_merge
(
value
,
hash
)
}
{
include:
hash_or_merge
(
value
,
hash
)
}
end
end
...
...
spec/features/projects/import_export/import_file_spec.rb
View file @
7f853e22
...
...
@@ -3,8 +3,9 @@ require 'spec_helper'
feature
'project import'
,
feature:
true
,
js:
true
do
include
Select2Helper
let
(
:user
)
{
create
(
:admin
)
}
let!
(
:namespace
)
{
create
(
:namespace
,
name:
"asd"
,
owner:
user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:normal_user
)
{
create
(
:user
)
}
let!
(
:namespace
)
{
create
(
:namespace
,
name:
"asd"
,
owner:
admin
)
}
let
(
:file
)
{
File
.
join
(
Rails
.
root
,
'spec'
,
'features'
,
'projects'
,
'import_export'
,
'test_project_export.tar.gz'
)
}
let
(
:export_path
)
{
"
#{
Dir
::
tmpdir
}
/import_file_spec"
}
let
(
:project
)
{
Project
.
last
}
...
...
@@ -12,66 +13,87 @@ feature 'project import', feature: true, js: true do
background
do
allow_any_instance_of
(
Gitlab
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
export_path
)
login_as
(
user
)
end
after
(
:each
)
do
FileUtils
.
rm_rf
(
export_path
,
secure:
true
)
end
scenario
'user imports an exported project successfully'
do
expect
(
Project
.
all
.
count
).
to
be_zero
context
'admin user'
do
before
do
login_as
(
admin
)
end
visit
new_project_path
scenario
'user imports an exported project successfully'
do
expect
(
Project
.
all
.
count
).
to
be_zero
select2
(
'2'
,
from:
'#project_namespace_id'
)
fill_in
:project_path
,
with:
'test-project-path'
,
visible:
true
click_link
'GitLab export'
visit
new_project_path
expect
(
page
).
to
have_content
(
'GitLab project export'
)
expect
(
URI
.
parse
(
current_url
).
query
).
to
eq
(
'namespace_id=2&path=test-project-path'
)
select2
(
'2'
,
from:
'#project_namespace_id'
)
fill_in
:project_path
,
with:
'test-project-path'
,
visible:
true
click_link
'GitLab export'
attach_file
(
'file'
,
file
)
expect
(
page
).
to
have_content
(
'GitLab project export'
)
expect
(
URI
.
parse
(
current_url
).
query
).
to
eq
(
'namespace_id=2&path=test-project-path'
)
click_on
'Import project'
# import starts
attach_file
(
'file'
,
file
)
expect
(
project
).
not_to
be_nil
expect
(
project
.
issues
).
not_to
be_empty
expect
(
project
.
merge_requests
).
not_to
be_empty
expect
(
project_hook
).
to
exist
expect
(
wiki_exists?
).
to
be
true
expect
(
project
.
import_status
).
to
eq
(
'finished'
)
end
click_on
'Import project'
# import starts
expect
(
project
).
not_to
be_nil
expect
(
project
.
issues
).
not_to
be_empty
expect
(
project
.
merge_requests
).
not_to
be_empty
expect
(
project_hook
).
to
exist
expect
(
wiki_exists?
).
to
be
true
expect
(
project
.
import_status
).
to
eq
(
'finished'
)
end
scenario
'invalid project'
do
project
=
create
(
:project
,
namespace_id:
2
)
scenario
'invalid project'
do
project
=
create
(
:project
,
namespace_id:
2
)
visit
new_project_path
visit
new_project_path
select2
(
'2'
,
from:
'#project_namespace_id'
)
fill_in
:project_path
,
with:
project
.
name
,
visible:
true
click_link
'GitLab export'
select2
(
'2'
,
from:
'#project_namespace_id'
)
fill_in
:project_path
,
with:
project
.
name
,
visible:
true
click_link
'GitLab export'
attach_file
(
'file'
,
file
)
click_on
'Import project'
attach_file
(
'file'
,
file
)
click_on
'Import project'
page
.
within
(
'.flash-container'
)
do
expect
(
page
).
to
have_content
(
'Project could not be imported'
)
page
.
within
(
'.flash-container'
)
do
expect
(
page
).
to
have_content
(
'Project could not be imported'
)
end
end
scenario
'project with no name'
do
create
(
:project
,
namespace_id:
2
)
visit
new_project_path
select2
(
'2'
,
from:
'#project_namespace_id'
)
# click on disabled element
find
(
:link
,
'GitLab export'
).
trigger
(
'click'
)
page
.
within
(
'.flash-container'
)
do
expect
(
page
).
to
have_content
(
'Please enter path and name'
)
end
end
end
scenario
'project with no name'
do
create
(
:project
,
namespace_id:
2
)
context
'normal user'
do
before
do
login_as
(
normal_user
)
end
visit
new_project_path
scenario
'non-admin user is not allowed to import a project'
do
expect
(
Project
.
all
.
count
).
to
be_zero
select2
(
'2'
,
from:
'#project_namespace_id'
)
visit
new_project_path
# click on disabled element
find
(
:link
,
'GitLab export'
).
trigger
(
'click'
)
fill_in
:project_path
,
with:
'test-project-path'
,
visible:
true
page
.
within
(
'.flash-container'
)
do
expect
(
page
).
to
have_content
(
'Please enter path and name'
)
expect
(
page
).
not_to
have_content
(
'GitLab export'
)
end
end
...
...
spec/lib/gitlab/import_export/reader_spec.rb
View file @
7f853e22
...
...
@@ -12,7 +12,8 @@ describe Gitlab::ImportExport::Reader, lib: true do
except:
[
:iid
],
include:
[
:merge_request_diff
,
:merge_request_test
]
}
},
{
commit_statuses:
{
include: :commit
}
}]
{
commit_statuses:
{
include: :commit
}
},
{
project_members:
{
include:
{
user:
{
only:
[
:email
]
}
}
}
}]
}
end
...
...
spec/support/import_export/import_export.yml
View file @
7f853e22
...
...
@@ -7,6 +7,8 @@ project_tree:
-
:merge_request_test
-
commit_statuses
:
-
:commit
-
project_members
:
-
:user
included_attributes
:
project
:
...
...
@@ -14,6 +16,8 @@ included_attributes:
-
:path
merge_requests
:
-
:id
user
:
-
:email
excluded_attributes
:
merge_requests
:
...
...
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