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
2b176137
Commit
2b176137
authored
Feb 28, 2018
by
Travis Miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
review: instantiate shared import/export object in project method
parent
0d8aadeb
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
21 additions
and
17 deletions
+21
-17
app/models/project.rb
app/models/project.rb
+6
-2
app/services/projects/import_export/export_service.rb
app/services/projects/import_export/export_service.rb
+1
-1
lib/gitlab/import_export/importer.rb
lib/gitlab/import_export/importer.rb
+1
-1
spec/lib/gitlab/import_export/avatar_restorer_spec.rb
spec/lib/gitlab/import_export/avatar_restorer_spec.rb
+1
-1
spec/lib/gitlab/import_export/avatar_saver_spec.rb
spec/lib/gitlab/import_export/avatar_saver_spec.rb
+1
-1
spec/lib/gitlab/import_export/fork_spec.rb
spec/lib/gitlab/import_export/fork_spec.rb
+1
-1
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+3
-3
spec/lib/gitlab/import_export/project_tree_saver_spec.rb
spec/lib/gitlab/import_export/project_tree_saver_spec.rb
+1
-1
spec/lib/gitlab/import_export/repo_restorer_spec.rb
spec/lib/gitlab/import_export/repo_restorer_spec.rb
+1
-1
spec/lib/gitlab/import_export/repo_saver_spec.rb
spec/lib/gitlab/import_export/repo_saver_spec.rb
+1
-1
spec/lib/gitlab/import_export/uploads_restorer_spec.rb
spec/lib/gitlab/import_export/uploads_restorer_spec.rb
+1
-1
spec/lib/gitlab/import_export/uploads_saver_spec.rb
spec/lib/gitlab/import_export/uploads_saver_spec.rb
+1
-1
spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb
spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb
+1
-1
spec/lib/gitlab/import_export/wiki_restorer_spec.rb
spec/lib/gitlab/import_export/wiki_restorer_spec.rb
+1
-1
No files found.
app/models/project.rb
View file @
2b176137
...
@@ -1557,10 +1557,14 @@ class Project < ActiveRecord::Base
...
@@ -1557,10 +1557,14 @@ class Project < ActiveRecord::Base
end
end
end
end
def
import_export
@import_export
||=
Gitlab
::
ImportExport
::
Shared
.
new
(
self
)
end
def
export_path
def
export_path
return
nil
unless
namespace
.
present?
||
hashed_storage?
(
:repository
)
return
nil
unless
namespace
.
present?
||
hashed_storage?
(
:repository
)
Gitlab
::
ImportExport
::
Shared
.
new
(
self
)
.
archive_path
import_export
.
archive_path
end
end
def
export_project_path
def
export_project_path
...
@@ -1578,7 +1582,7 @@ class Project < ActiveRecord::Base
...
@@ -1578,7 +1582,7 @@ class Project < ActiveRecord::Base
end
end
def
export_in_progress?
def
export_in_progress?
Gitlab
::
ImportExport
::
Shared
.
new
(
self
)
.
active_export_count
>
0
import_export
.
active_export_count
>
0
end
end
def
remove_exports
def
remove_exports
...
...
app/services/projects/import_export/export_service.rb
View file @
2b176137
...
@@ -2,7 +2,7 @@ module Projects
...
@@ -2,7 +2,7 @@ module Projects
module
ImportExport
module
ImportExport
class
ExportService
<
BaseService
class
ExportService
<
BaseService
def
execute
(
_options
=
{})
def
execute
(
_options
=
{})
@shared
=
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
@shared
=
project
.
import_export
save_all
save_all
end
end
...
...
lib/gitlab/import_export/importer.rb
View file @
2b176137
...
@@ -9,7 +9,7 @@ module Gitlab
...
@@ -9,7 +9,7 @@ module Gitlab
@archive_file
=
project
.
import_source
@archive_file
=
project
.
import_source
@current_user
=
project
.
creator
@current_user
=
project
.
creator
@project
=
project
@project
=
project
@shared
=
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
@shared
=
project
.
import_export
end
end
def
execute
def
execute
...
...
spec/lib/gitlab/import_export/avatar_restorer_spec.rb
View file @
2b176137
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
ImportExport
::
AvatarRestorer
do
describe
Gitlab
::
ImportExport
::
AvatarRestorer
do
include
UploadHelpers
include
UploadHelpers
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
before
do
before
do
...
...
spec/lib/gitlab/import_export/avatar_saver_spec.rb
View file @
2b176137
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
ImportExport
::
AvatarSaver
do
describe
Gitlab
::
ImportExport
::
AvatarSaver
do
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:project_with_avatar
)
{
create
(
:project
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"image/png"
))
}
let
(
:project_with_avatar
)
{
create
(
:project
,
avatar:
fixture_file_upload
(
Rails
.
root
+
"spec/fixtures/dk.png"
,
"image/png"
))
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
...
...
spec/lib/gitlab/import_export/fork_spec.rb
View file @
2b176137
...
@@ -7,7 +7,7 @@ describe 'forked project import' do
...
@@ -7,7 +7,7 @@ describe 'forked project import' do
let!
(
:project_with_repo
)
{
create
(
:project
,
:repository
,
name:
'test-repo-restorer'
,
path:
'test-repo-restorer'
)
}
let!
(
:project_with_repo
)
{
create
(
:project
,
:repository
,
name:
'test-repo-restorer'
,
path:
'test-repo-restorer'
)
}
let!
(
:project
)
{
create
(
:project
,
name:
'test-repo-restorer-no-repo'
,
path:
'test-repo-restorer-no-repo'
)
}
let!
(
:project
)
{
create
(
:project
,
name:
'test-repo-restorer-no-repo'
,
path:
'test-repo-restorer-no-repo'
)
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
let
(
:forked_from_project
)
{
create
(
:project
,
:repository
)
}
let
(
:forked_from_project
)
{
create
(
:project
,
:repository
)
}
let
(
:forked_project
)
{
fork_project
(
project_with_repo
,
nil
,
repository:
true
)
}
let
(
:forked_project
)
{
fork_project
(
project_with_repo
,
nil
,
repository:
true
)
}
let
(
:repo_saver
)
{
Gitlab
::
ImportExport
::
RepoSaver
.
new
(
project:
project_with_repo
,
shared:
shared
)
}
let
(
:repo_saver
)
{
Gitlab
::
ImportExport
::
RepoSaver
.
new
(
project:
project_with_repo
,
shared:
shared
)
}
...
...
spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
View file @
2b176137
...
@@ -7,9 +7,9 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
...
@@ -7,9 +7,9 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
@user
=
create
(
:user
)
@user
=
create
(
:user
)
RSpec
::
Mocks
.
with_temporary_scope
do
RSpec
::
Mocks
.
with_temporary_scope
do
@shared
=
Gitlab
::
ImportExport
::
Shared
.
new
(
@project
)
allow
(
@shared
).
to
receive
(
:export_path
).
and_return
(
'spec/lib/gitlab/import_export/'
)
@project
=
create
(
:project
,
:builds_disabled
,
:issues_disabled
,
name:
'project'
,
path:
'project'
)
@project
=
create
(
:project
,
:builds_disabled
,
:issues_disabled
,
name:
'project'
,
path:
'project'
)
@shared
=
@project
.
import_export
allow
(
@shared
).
to
receive
(
:export_path
).
and_return
(
'spec/lib/gitlab/import_export/'
)
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_ref
).
and_return
(
true
)
allow_any_instance_of
(
Repository
).
to
receive
(
:fetch_ref
).
and_return
(
true
)
allow_any_instance_of
(
Gitlab
::
Git
::
Repository
).
to
receive
(
:branch_exists?
).
and_return
(
false
)
allow_any_instance_of
(
Gitlab
::
Git
::
Repository
).
to
receive
(
:branch_exists?
).
and_return
(
false
)
...
@@ -259,7 +259,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
...
@@ -259,7 +259,7 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
context
'Light JSON'
do
context
'Light JSON'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
let!
(
:project
)
{
create
(
:project
,
:builds_disabled
,
:issues_disabled
,
name:
'project'
,
path:
'project'
)
}
let!
(
:project
)
{
create
(
:project
,
:builds_disabled
,
:issues_disabled
,
name:
'project'
,
path:
'project'
)
}
let
(
:project_tree_restorer
)
{
described_class
.
new
(
user:
user
,
shared:
shared
,
project:
project
)
}
let
(
:project_tree_restorer
)
{
described_class
.
new
(
user:
user
,
shared:
shared
,
project:
project
)
}
let
(
:restored_project_json
)
{
project_tree_restorer
.
restore
}
let
(
:restored_project_json
)
{
project_tree_restorer
.
restore
}
...
...
spec/lib/gitlab/import_export/project_tree_saver_spec.rb
View file @
2b176137
...
@@ -2,7 +2,7 @@ require 'spec_helper'
...
@@ -2,7 +2,7 @@ require 'spec_helper'
describe
Gitlab
::
ImportExport
::
ProjectTreeSaver
do
describe
Gitlab
::
ImportExport
::
ProjectTreeSaver
do
describe
'saves the project tree into a json object'
do
describe
'saves the project tree into a json object'
do
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
let
(
:project_tree_saver
)
{
described_class
.
new
(
project:
project
,
current_user:
user
,
shared:
shared
)
}
let
(
:project_tree_saver
)
{
described_class
.
new
(
project:
project
,
current_user:
user
,
shared:
shared
)
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
...
...
spec/lib/gitlab/import_export/repo_restorer_spec.rb
View file @
2b176137
...
@@ -6,7 +6,7 @@ describe Gitlab::ImportExport::RepoRestorer do
...
@@ -6,7 +6,7 @@ describe Gitlab::ImportExport::RepoRestorer do
let!
(
:project_with_repo
)
{
create
(
:project
,
:repository
,
name:
'test-repo-restorer'
,
path:
'test-repo-restorer'
)
}
let!
(
:project_with_repo
)
{
create
(
:project
,
:repository
,
name:
'test-repo-restorer'
,
path:
'test-repo-restorer'
)
}
let!
(
:project
)
{
create
(
:project
)
}
let!
(
:project
)
{
create
(
:project
)
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
let
(
:bundler
)
{
Gitlab
::
ImportExport
::
RepoSaver
.
new
(
project:
project_with_repo
,
shared:
shared
)
}
let
(
:bundler
)
{
Gitlab
::
ImportExport
::
RepoSaver
.
new
(
project:
project_with_repo
,
shared:
shared
)
}
let
(
:bundle_path
)
{
File
.
join
(
shared
.
export_path
,
Gitlab
::
ImportExport
.
project_bundle_filename
)
}
let
(
:bundle_path
)
{
File
.
join
(
shared
.
export_path
,
Gitlab
::
ImportExport
.
project_bundle_filename
)
}
let
(
:restorer
)
do
let
(
:restorer
)
do
...
...
spec/lib/gitlab/import_export/repo_saver_spec.rb
View file @
2b176137
...
@@ -5,7 +5,7 @@ describe Gitlab::ImportExport::RepoSaver do
...
@@ -5,7 +5,7 @@ describe Gitlab::ImportExport::RepoSaver do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
:public
,
name:
'searchable_project'
)
}
let!
(
:project
)
{
create
(
:project
,
:public
,
name:
'searchable_project'
)
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
let
(
:bundler
)
{
described_class
.
new
(
project:
project
,
shared:
shared
)
}
let
(
:bundler
)
{
described_class
.
new
(
project:
project
,
shared:
shared
)
}
before
do
before
do
...
...
spec/lib/gitlab/import_export/uploads_restorer_spec.rb
View file @
2b176137
...
@@ -3,7 +3,7 @@ require 'spec_helper'
...
@@ -3,7 +3,7 @@ require 'spec_helper'
describe
Gitlab
::
ImportExport
::
UploadsRestorer
do
describe
Gitlab
::
ImportExport
::
UploadsRestorer
do
describe
'bundle a project Git repo'
do
describe
'bundle a project Git repo'
do
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/uploads_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/uploads_saver_spec"
}
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
before
do
before
do
allow_any_instance_of
(
Gitlab
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
export_path
)
allow_any_instance_of
(
Gitlab
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
export_path
)
...
...
spec/lib/gitlab/import_export/uploads_saver_spec.rb
View file @
2b176137
...
@@ -4,7 +4,7 @@ describe Gitlab::ImportExport::UploadsSaver do
...
@@ -4,7 +4,7 @@ describe Gitlab::ImportExport::UploadsSaver do
describe
'bundle a project Git repo'
do
describe
'bundle a project Git repo'
do
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/uploads_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/uploads_saver_spec"
}
let
(
:file
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:file
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
before
do
before
do
allow_any_instance_of
(
Gitlab
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
export_path
)
allow_any_instance_of
(
Gitlab
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
export_path
)
...
...
spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb
View file @
2b176137
...
@@ -5,7 +5,7 @@ describe Gitlab::ImportExport::WikiRepoSaver do
...
@@ -5,7 +5,7 @@ describe Gitlab::ImportExport::WikiRepoSaver do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
:public
,
name:
'searchable_project'
)
}
let!
(
:project
)
{
create
(
:project
,
:public
,
name:
'searchable_project'
)
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
let
(
:wiki_bundler
)
{
described_class
.
new
(
project:
project
,
shared:
shared
)
}
let
(
:wiki_bundler
)
{
described_class
.
new
(
project:
project
,
shared:
shared
)
}
let!
(
:project_wiki
)
{
ProjectWiki
.
new
(
project
,
user
)
}
let!
(
:project_wiki
)
{
ProjectWiki
.
new
(
project
,
user
)
}
...
...
spec/lib/gitlab/import_export/wiki_restorer_spec.rb
View file @
2b176137
...
@@ -6,7 +6,7 @@ describe Gitlab::ImportExport::WikiRestorer do
...
@@ -6,7 +6,7 @@ describe Gitlab::ImportExport::WikiRestorer do
let!
(
:project_without_wiki
)
{
create
(
:project
)
}
let!
(
:project_without_wiki
)
{
create
(
:project
)
}
let!
(
:project
)
{
create
(
:project
)
}
let!
(
:project
)
{
create
(
:project
)
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
.
tmpdir
}
/project_tree_saver_spec"
}
let
(
:shared
)
{
Gitlab
::
ImportExport
::
Shared
.
new
(
project
)
}
let
(
:shared
)
{
project
.
import_export
}
let
(
:bundler
)
{
Gitlab
::
ImportExport
::
WikiRepoSaver
.
new
(
project:
project_with_wiki
,
shared:
shared
)
}
let
(
:bundler
)
{
Gitlab
::
ImportExport
::
WikiRepoSaver
.
new
(
project:
project_with_wiki
,
shared:
shared
)
}
let
(
:bundle_path
)
{
File
.
join
(
shared
.
export_path
,
Gitlab
::
ImportExport
.
project_bundle_filename
)
}
let
(
:bundle_path
)
{
File
.
join
(
shared
.
export_path
,
Gitlab
::
ImportExport
.
project_bundle_filename
)
}
let
(
:restorer
)
do
let
(
:restorer
)
do
...
...
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