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
4e73f982
Commit
4e73f982
authored
Mar 08, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP - started working on bundle the repo, refactored some stuff and updated spec
parent
68eae045
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
9 deletions
+74
-9
app/services/projects/import_export/command_line_util.rb
app/services/projects/import_export/command_line_util.rb
+11
-0
app/services/projects/import_export/export_service.rb
app/services/projects/import_export/export_service.rb
+7
-1
app/services/projects/import_export/project_tree_saver.rb
app/services/projects/import_export/project_tree_saver.rb
+4
-7
app/services/projects/import_export/repo_bundler.rb
app/services/projects/import_export/repo_bundler.rb
+37
-0
app/services/projects/import_export/shared.rb
app/services/projects/import_export/shared.rb
+13
-0
spec/services/projects/import_export/project_tree_saver_spec.rb
...ervices/projects/import_export/project_tree_saver_spec.rb
+2
-1
No files found.
app/services/projects/import_export/command_line_util.rb
0 → 100644
View file @
4e73f982
module
Projects
module
ImportExport
module
CommandLineUtil
def
tar_cf
(
archive
:,
dir
:)
cmd
=
%W(tar -cf
#{
archive
}
-C
#{
dir
}
.)
_output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
status
.
zero?
end
end
end
end
app/services/projects/import_export/export_service.rb
View file @
4e73f982
...
@@ -2,13 +2,19 @@ module Projects
...
@@ -2,13 +2,19 @@ module Projects
module
ImportExport
module
ImportExport
class
ExportService
<
BaseService
class
ExportService
<
BaseService
def
execute
(
options
=
{})
def
execute
(
options
=
{})
@shared
=
Projects
::
ImportExport
::
Shared
.
new
(
project_name:
@project_name
)
save_project_tree
save_project_tree
bundle_repo
end
end
private
private
def
save_project_tree
def
save_project_tree
Projects
::
ImportExport
::
ProjectTreeSaver
.
save
(
project:
project
)
Projects
::
ImportExport
::
ProjectTreeSaver
.
new
(
project:
project
,
shared:
@shared
).
save
end
def
bundle_repo
Projects
::
ImportExport
::
RepoBundler
.
new
(
project:
project
,
shared:
@shared
).
bundle
end
end
end
end
end
end
...
...
app/services/projects/import_export/project_tree_saver.rb
View file @
4e73f982
...
@@ -3,19 +3,20 @@ module Projects
...
@@ -3,19 +3,20 @@ module Projects
class
ProjectTreeSaver
class
ProjectTreeSaver
attr_reader
:full_path
attr_reader
:full_path
def
initialize
(
project:
)
def
initialize
(
project:
,
shared:
)
@project
=
project
@project
=
project
@export_path
=
shared
.
export_path
end
end
def
save
def
save
@full_path
=
File
.
join
(
export_path
,
project_filename
)
@full_path
=
File
.
join
(
@
export_path
,
project_filename
)
save_to_disk
save_to_disk
end
end
private
private
def
save_to_disk
def
save_to_disk
FileUtils
.
mkdir_p
(
export_path
)
FileUtils
.
mkdir_p
(
@
export_path
)
File
.
write
(
full_path
,
project_json_tree
)
File
.
write
(
full_path
,
project_json_tree
)
true
true
rescue
rescue
...
@@ -23,10 +24,6 @@ module Projects
...
@@ -23,10 +24,6 @@ module Projects
false
false
end
end
def
export_path
@export_path
||=
ImportExport
.
export_path
(
@project
.
name
)
end
def
project_filename
def
project_filename
# TODO sanitize name
# TODO sanitize name
"
#{
@project
.
name
}
.json"
"
#{
@project
.
name
}
.json"
...
...
app/services/projects/import_export/repo_bundler.rb
0 → 100644
View file @
4e73f982
module
Projects
module
ImportExport
class
RepoBundler
include
Projects
::
ImportExport
::
CommandLineUtil
attr_reader
:full_path
def
initialize
(
project:
,
shared:
)
@project
=
project
@export_path
=
shared
.
export_path
end
def
bundle
return
false
if
project
.
empty_repo?
@full_path
=
File
.
join
(
export_path
,
project_filename
)
bundle_to_disk
end
private
def
bundle_to_disk
tar_cf
(
archive:
full_path
,
dir:
path_to_repo
)
rescue
#TODO: handle error
false
end
def
project_filename
@project
.
path_with_namespace
+
".bundle"
end
def
path_to_repo
@project
.
repository
.
path_to_repo
end
end
end
end
app/services/projects/import_export/shared.rb
0 → 100644
View file @
4e73f982
module
Projects
module
ImportExport
class
Shared
def
initialize
(
opts
)
@opts
=
opts
end
def
export_path
@export_path
||=
ImportExport
.
export_path
(
project_name:
@opts
[
:project_name
])
end
end
end
end
\ No newline at end of file
spec/services/projects/import_export/project_tree_saver_spec.rb
View file @
4e73f982
...
@@ -23,7 +23,8 @@ describe Projects::ImportExport::ProjectTreeSaver, services: true do
...
@@ -23,7 +23,8 @@ describe Projects::ImportExport::ProjectTreeSaver, services: true do
end
end
let!
(
:milestone
)
{
create
(
:milestone
,
title:
"Milestone v1.2"
,
project:
project
)
}
let!
(
:milestone
)
{
create
(
:milestone
,
title:
"Milestone v1.2"
,
project:
project
)
}
let
(
:export_path
)
{
"
#{
Dir
::
tmpdir
}
/project_tree_saver_spec"
}
let
(
:export_path
)
{
"
#{
Dir
::
tmpdir
}
/project_tree_saver_spec"
}
let
(
:project_tree_saver
)
{
Projects
::
ImportExport
::
ProjectTreeSaver
.
new
(
project:
project
)
}
let
(
:shared
)
{
Projects
::
ImportExport
::
Shared
.
new
(
project_name:
@project_name
)
}
let
(
:project_tree_saver
)
{
Projects
::
ImportExport
::
ProjectTreeSaver
.
new
(
project:
project
,
shared:
shared
)
}
before
(
:each
)
do
before
(
:each
)
do
project
.
team
<<
[
user
,
:master
]
project
.
team
<<
[
user
,
:master
]
...
...
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