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
556cafa4
Commit
556cafa4
authored
Mar 08, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added repo bundler spec and refactored some of the export code
parent
4e73f982
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
9 deletions
+35
-9
app/services/projects/import_export.rb
app/services/projects/import_export.rb
+2
-2
app/services/projects/import_export/export_service.rb
app/services/projects/import_export/export_service.rb
+1
-1
app/services/projects/import_export/repo_bundler.rb
app/services/projects/import_export/repo_bundler.rb
+4
-3
app/services/projects/import_export/shared.rb
app/services/projects/import_export/shared.rb
+1
-1
spec/services/projects/import_export/project_tree_saver_spec.rb
...ervices/projects/import_export/project_tree_saver_spec.rb
+2
-2
spec/services/projects/import_export/repo_bundler_spec.rb
spec/services/projects/import_export/repo_bundler_spec.rb
+25
-0
No files found.
app/services/projects/import_export.rb
View file @
556cafa4
...
...
@@ -2,8 +2,8 @@ module Projects
module
ImportExport
extend
self
def
export_path
(
project_name
:)
File
.
join
(
storage_path
,
"
#{
Time
.
now
.
strftime
(
'%Y-%m-%d_%H-%M-%3N'
)
}
_gitlab_export
_
#{
project_name
}
"
)
def
export_path
(
relative_path
:)
File
.
join
(
storage_path
,
"
#{
Time
.
now
.
strftime
(
'%Y-%m-%d_%H-%M-%3N'
)
}
_gitlab_export
/
#{
relative_path
}
"
)
end
def
project_atts
...
...
app/services/projects/import_export/export_service.rb
View file @
556cafa4
...
...
@@ -2,7 +2,7 @@ module Projects
module
ImportExport
class
ExportService
<
BaseService
def
execute
(
options
=
{})
@shared
=
Projects
::
ImportExport
::
Shared
.
new
(
project_name:
@project_nam
e
)
@shared
=
Projects
::
ImportExport
::
Shared
.
new
(
relative_path:
project
.
path_with_namespac
e
)
save_project_tree
bundle_repo
end
...
...
app/services/projects/import_export/repo_bundler.rb
View file @
556cafa4
...
...
@@ -11,14 +11,15 @@ module Projects
end
def
bundle
return
false
if
project
.
empty_repo?
@full_path
=
File
.
join
(
export_path
,
project_filename
)
return
false
if
@
project
.
empty_repo?
@full_path
=
File
.
join
(
@
export_path
,
project_filename
)
bundle_to_disk
end
private
def
bundle_to_disk
FileUtils
.
mkdir_p
(
@export_path
)
tar_cf
(
archive:
full_path
,
dir:
path_to_repo
)
rescue
#TODO: handle error
...
...
@@ -26,7 +27,7 @@ module Projects
end
def
project_filename
@project
.
path_with_namespace
+
"
.bundle"
"
#{
@project
.
namespace
}#{
@project
.
name
}
.bundle"
end
def
path_to_repo
...
...
app/services/projects/import_export/shared.rb
View file @
556cafa4
...
...
@@ -6,7 +6,7 @@ module Projects
end
def
export_path
@export_path
||=
ImportExport
.
export_path
(
project_name:
@opts
[
:project_name
])
@export_path
||=
Projects
::
ImportExport
.
export_path
(
relative_path:
@opts
[
:relative_path
])
end
end
end
...
...
spec/services/projects/import_export/project_tree_saver_spec.rb
View file @
556cafa4
...
...
@@ -23,12 +23,12 @@ describe Projects::ImportExport::ProjectTreeSaver, services: true do
end
let!
(
:milestone
)
{
create
(
:milestone
,
title:
"Milestone v1.2"
,
project:
project
)
}
let
(
:export_path
)
{
"
#{
Dir
::
tmpdir
}
/project_tree_saver_spec"
}
let
(
:shared
)
{
Projects
::
ImportExport
::
Shared
.
new
(
project_name:
@project_nam
e
)
}
let
(
:shared
)
{
Projects
::
ImportExport
::
Shared
.
new
(
relative_path:
project
.
path_with_namespac
e
)
}
let
(
:project_tree_saver
)
{
Projects
::
ImportExport
::
ProjectTreeSaver
.
new
(
project:
project
,
shared:
shared
)
}
before
(
:each
)
do
project
.
team
<<
[
user
,
:master
]
allow_any_instance_of
(
Projects
::
ImportExport
::
ProjectTreeSaver
).
to
receive
(
:export
_path
).
and_return
(
export_path
)
allow_any_instance_of
(
Projects
::
ImportExport
).
to
receive
(
:storage
_path
).
and_return
(
export_path
)
end
after
(
:each
)
do
...
...
spec/services/projects/import_export/repo_bundler_spec.rb
0 → 100644
View file @
556cafa4
require
'spec_helper'
describe
Projects
::
ImportExport
::
RepoBundler
,
services:
true
do
describe
:bundle
do
let
(
:user
)
{
create
(
:user
)
}
let!
(
:project
)
{
create
(
:project
,
:public
,
name:
'searchable_project'
)
}
let
(
:export_path
)
{
"
#{
Dir
::
tmpdir
}
/project_tree_saver_spec"
}
let
(
:shared
)
{
Projects
::
ImportExport
::
Shared
.
new
(
relative_path:
project
.
path_with_namespace
)
}
let
(
:bundler
)
{
Projects
::
ImportExport
::
RepoBundler
.
new
(
project:
project
,
shared:
shared
)
}
before
(
:each
)
do
project
.
team
<<
[
user
,
:master
]
allow_any_instance_of
(
Projects
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
export_path
)
end
after
(
:each
)
do
FileUtils
.
rm_rf
(
export_path
)
end
it
'bundles the repo successfully'
do
expect
(
bundler
.
bundle
).
to
be
true
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