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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
430991b0
Commit
430991b0
authored
Jul 16, 2019
by
Luke Duncalfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for exporting design repositories
https://gitlab.com/gitlab-org/gitlab-ee/issues/11090
parent
64d10109
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
254 additions
and
0 deletions
+254
-0
app/services/projects/import_export/export_service.rb
app/services/projects/import_export/export_service.rb
+2
-0
ee/app/services/ee/projects/import_export/export_service.rb
ee/app/services/ee/projects/import_export/export_service.rb
+19
-0
ee/lib/ee/gitlab/import_export.rb
ee/lib/ee/gitlab/import_export.rb
+11
-0
ee/lib/ee/gitlab/import_export/importer.rb
ee/lib/ee/gitlab/import_export/importer.rb
+27
-0
ee/lib/gitlab/import_export/design_repo_restorer.rb
ee/lib/gitlab/import_export/design_repo_restorer.rb
+15
-0
ee/lib/gitlab/import_export/design_repo_saver.rb
ee/lib/gitlab/import_export/design_repo_saver.rb
+19
-0
ee/spec/factories/projects.rb
ee/spec/factories/projects.rb
+6
-0
ee/spec/lib/gitlab/import_export/design_repo_restorer_spec.rb
...pec/lib/gitlab/import_export/design_repo_restorer_spec.rb
+40
-0
ee/spec/lib/gitlab/import_export/design_repo_saver_spec.rb
ee/spec/lib/gitlab/import_export/design_repo_saver_spec.rb
+35
-0
ee/spec/lib/gitlab/import_export/importer_spec.rb
ee/spec/lib/gitlab/import_export/importer_spec.rb
+45
-0
ee/spec/services/projects/import_export/export_service_spec.rb
...ec/services/projects/import_export/export_service_spec.rb
+31
-0
lib/gitlab/import_export.rb
lib/gitlab/import_export.rb
+2
-0
lib/gitlab/import_export/importer.rb
lib/gitlab/import_export/importer.rb
+2
-0
No files found.
app/services/projects/import_export/export_service.rb
View file @
430991b0
...
...
@@ -91,3 +91,5 @@ module Projects
end
end
end
Projects
::
ImportExport
::
ExportService
.
prepend_if_ee
(
'EE::Projects::ImportExport::ExportService'
)
ee/app/services/ee/projects/import_export/export_service.rb
0 → 100644
View file @
430991b0
# frozen_string_literal: true
module
EE::Projects::ImportExport::ExportService
extend
ActiveSupport
::
Concern
extend
::
Gitlab
::
Utils
::
Override
private
override
:exporters
def
exporters
super
+
Array
.
wrap
(
design_repo_saver
)
end
def
design_repo_saver
return
unless
Feature
.
enabled?
(
:export_designs
,
project
,
default_enabled:
true
)
Gitlab
::
ImportExport
::
DesignRepoSaver
.
new
(
project:
project
,
shared:
shared
)
end
end
ee/lib/ee/gitlab/import_export.rb
0 → 100644
View file @
430991b0
# frozen_string_literal: true
module
EE::Gitlab::ImportExport
extend
ActiveSupport
::
Concern
prepended
do
def
design_repo_bundle_filename
'project.design.bundle'
end
end
end
ee/lib/ee/gitlab/import_export/importer.rb
0 → 100644
View file @
430991b0
# frozen_string_literal: true
module
EE::Gitlab::ImportExport::Importer
extend
ActiveSupport
::
Concern
extend
::
Gitlab
::
Utils
::
Override
private
override
:restorers
def
restorers
super
+
Array
.
wrap
(
design_repo_restorer
)
end
def
design_repo_restorer
return
unless
Feature
.
enabled?
(
:export_designs
,
project
,
default_enabled:
true
)
Gitlab
::
ImportExport
::
DesignRepoRestorer
.
new
(
path_to_bundle:
design_repo_path
,
shared:
shared
,
project:
project_tree
.
restored_project
)
end
def
design_repo_path
File
.
join
(
shared
.
export_path
,
::
Gitlab
::
ImportExport
.
design_repo_bundle_filename
)
end
end
ee/lib/gitlab/import_export/design_repo_restorer.rb
0 → 100644
View file @
430991b0
# frozen_string_literal: true
module
Gitlab
module
ImportExport
class
DesignRepoRestorer
<
RepoRestorer
def
initialize
(
project
:,
shared
:,
path_to_bundle
:)
super
(
project:
project
,
shared:
shared
,
path_to_bundle:
path_to_bundle
)
@repository
=
project
.
design_repository
end
# `restore` method is handled in super class
end
end
end
ee/lib/gitlab/import_export/design_repo_saver.rb
0 → 100644
View file @
430991b0
# frozen_string_literal: true
module
Gitlab
module
ImportExport
class
DesignRepoSaver
<
RepoSaver
def
save
@repository
=
project
.
design_repository
super
end
private
def
bundle_full_path
File
.
join
(
shared
.
export_path
,
::
Gitlab
::
ImportExport
.
design_repo_bundle_filename
)
end
end
end
end
ee/spec/factories/projects.rb
View file @
430991b0
...
...
@@ -30,6 +30,12 @@ FactoryBot.modify do
end
end
trait
:design_repo
do
after
(
:create
)
do
|
project
|
raise
'Failed to create design repository!'
unless
project
.
design_repository
.
create_if_not_exists
end
end
trait
:import_none
do
import_status
:none
end
...
...
ee/spec/lib/gitlab/import_export/design_repo_restorer_spec.rb
0 → 100644
View file @
430991b0
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
ImportExport
::
DesignRepoRestorer
do
include
GitHelpers
describe
'bundle a design Git repo'
do
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project_with_design_repo
)
{
create
(
:project
,
:design_repo
)
}
let!
(
:project
)
{
create
(
:project
)
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:shared
)
{
project
.
import_export_shared
}
let
(
:bundler
)
{
Gitlab
::
ImportExport
::
DesignRepoSaver
.
new
(
project:
project_with_design_repo
,
shared:
shared
)
}
let
(
:bundle_path
)
{
File
.
join
(
shared
.
export_path
,
Gitlab
::
ImportExport
.
design_repo_bundle_filename
)
}
let
(
:restorer
)
do
described_class
.
new
(
path_to_bundle:
bundle_path
,
shared:
shared
,
project:
project
)
end
before
do
allow_any_instance_of
(
Gitlab
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
export_path
)
bundler
.
save
end
after
do
FileUtils
.
rm_rf
(
export_path
)
Gitlab
::
GitalyClient
::
StorageSettings
.
allow_disk_access
do
FileUtils
.
rm_rf
(
project_with_design_repo
.
design_repository
.
path_to_repo
)
FileUtils
.
rm_rf
(
project
.
design_repository
.
path_to_repo
)
end
end
it
'restores the repo successfully'
do
expect
(
restorer
.
restore
).
to
eq
(
true
)
end
end
end
ee/spec/lib/gitlab/import_export/design_repo_saver_spec.rb
0 → 100644
View file @
430991b0
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
ImportExport
::
DesignRepoSaver
do
describe
'bundle a design Git repo'
do
set
(
:user
)
{
create
(
:user
)
}
set
(
:design
)
{
create
(
:design
,
:with_file
,
versions_count:
1
)
}
let!
(
:project
)
{
create
(
:project
,
:design_repo
)
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:shared
)
{
project
.
import_export_shared
}
let
(
:design_bundler
)
{
described_class
.
new
(
project:
project
,
shared:
shared
)
}
before
do
project
.
add_maintainer
(
user
)
allow_any_instance_of
(
Gitlab
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
export_path
)
end
after
do
FileUtils
.
rm_rf
(
export_path
)
end
it
'bundles the repo successfully'
do
expect
(
design_bundler
.
save
).
to
be
true
end
context
'when the repo is empty'
do
let!
(
:project
)
{
create
(
:project
)
}
it
'bundles the repo successfully'
do
expect
(
design_bundler
.
save
).
to
be
true
end
end
end
end
ee/spec/lib/gitlab/import_export/importer_spec.rb
0 → 100644
View file @
430991b0
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
ImportExport
::
Importer
do
describe
'#execute'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:test_path
)
{
"
#{
Dir
.
tmpdir
}
/importer_spec"
}
let
(
:shared
)
{
project
.
import_export_shared
}
let
(
:import_file
)
{
fixture_file_upload
(
'spec/features/projects/import_export/test_project_export.tar.gz'
)
}
subject
(
:importer
)
{
described_class
.
new
(
project
)
}
before
do
allow_any_instance_of
(
Gitlab
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
test_path
)
allow_any_instance_of
(
Gitlab
::
ImportExport
::
FileImporter
).
to
receive
(
:remove_import_file
)
stub_uploads_object_storage
(
FileUploader
)
FileUtils
.
mkdir_p
(
shared
.
export_path
)
ImportExportUpload
.
create
(
project:
project
,
import_file:
import_file
)
end
after
do
FileUtils
.
rm_rf
(
test_path
)
end
it
'restores the design repo'
do
expect
(
Gitlab
::
ImportExport
::
DesignRepoRestorer
).
to
receive
(
:new
).
and_call_original
importer
.
execute
end
context
'when the `export_designs` feature is disabled'
do
before
do
stub_feature_flags
(
export_designs:
false
)
end
it
'does not restore the design repo'
do
expect
(
Gitlab
::
ImportExport
::
DesignRepoRestorer
).
not_to
receive
(
:new
)
importer
.
execute
end
end
end
end
ee/spec/services/projects/import_export/export_service_spec.rb
0 → 100644
View file @
430991b0
# frozen_string_literal: true
require
'spec_helper'
describe
Projects
::
ImportExport
::
ExportService
do
describe
'#execute'
do
set
(
:user
)
{
create
(
:user
)
}
set
(
:project
)
{
create
(
:project
)
}
let
(
:shared
)
{
project
.
import_export_shared
}
let
(
:service
)
{
described_class
.
new
(
project
,
user
)
}
let!
(
:after_export_strategy
)
{
Gitlab
::
ImportExport
::
AfterExportStrategies
::
DownloadNotificationStrategy
.
new
}
it
'saves the design repo'
do
expect
(
Gitlab
::
ImportExport
::
DesignRepoSaver
).
to
receive
(
:new
).
and_call_original
service
.
execute
end
context
'when the `export_designs` feature is disabled'
do
before
do
stub_feature_flags
(
export_designs:
false
)
end
it
'does not save the design repo'
do
expect
(
Gitlab
::
ImportExport
::
DesignRepoSaver
).
not_to
receive
(
:new
)
service
.
execute
end
end
end
end
lib/gitlab/import_export.rb
View file @
430991b0
...
...
@@ -65,3 +65,5 @@ module Gitlab
end
end
end
Gitlab
::
ImportExport
.
prepend_if_ee
(
'EE::Gitlab::ImportExport'
)
lib/gitlab/import_export/importer.rb
View file @
430991b0
...
...
@@ -133,3 +133,5 @@ module Gitlab
end
end
end
Gitlab
::
ImportExport
::
Importer
.
prepend_if_ee
(
'EE::Gitlab::ImportExport::Importer'
)
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