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
Jérome Perrin
gitlab-ce
Commits
ae777ea0
Commit
ae777ea0
authored
Apr 15, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP - importing file and repo
parent
97c3aff1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
2 deletions
+80
-2
app/services/projects/import_export/import_service.rb
app/services/projects/import_export/import_service.rb
+9
-2
lib/gitlab/import_export/command_line_util.rb
lib/gitlab/import_export/command_line_util.rb
+14
-0
lib/gitlab/import_export/importer.rb
lib/gitlab/import_export/importer.rb
+26
-0
lib/gitlab/import_export/repo_restorer.rb
lib/gitlab/import_export/repo_restorer.rb
+31
-0
No files found.
app/services/projects/import_export/import_service.rb
View file @
ae777ea0
...
...
@@ -2,17 +2,24 @@ module Projects
module
ImportExport
class
ExportService
<
BaseService
def
execute
(
options
=
{})
@import_path
=
options
[
:import_path
]
restore_project_tree
restore_repo
(
project_tree
.
project
)
end
private
def
restore_project_tree
Gitlab
::
ImportExport
::
ProjectTreeRestorer
.
new
(
path:
@import_path
)
.
restore
project_tree
.
restore
end
def
restore_repo
def
project_tree
@project_tree
||=
Gitlab
::
ImportExport
::
ProjectTreeRestorer
.
new
(
path:
@import_path
,
user:
@current_user
)
end
def
restore_repo
(
project
)
Gitlab
::
ImportExport
::
RepoRestorer
.
new
(
path:
@import_path
,
project:
project
).
restore
end
end
end
...
...
lib/gitlab/import_export/command_line_util.rb
View file @
ae777ea0
...
...
@@ -5,6 +5,14 @@ module Gitlab
tar_with_options
(
archive:
archive
,
dir:
dir
,
options:
'cf'
)
end
def
untar_czf
(
archive
:,
dir
:)
untar_with_options
(
archive:
archive
,
dir:
dir
,
options:
'czf'
)
end
def
untar_cf
(
archive
:,
dir
:)
untar_with_options
(
archive:
archive
,
dir:
dir
,
options:
'cf'
)
end
def
tar_czf
(
archive
:,
dir
:)
tar_with_options
(
archive:
archive
,
dir:
dir
,
options:
'czf'
)
end
...
...
@@ -20,6 +28,12 @@ module Gitlab
_output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
status
.
zero?
end
def
untar_with_options
(
archive
:,
dir
:,
options
:)
cmd
=
%W(tar -
#{
options
}
#{
archive
)
}
-C
#{
dir
}
)
_output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
status
.
zero?
end
end
end
end
lib/gitlab/import_export/importer.rb
0 → 100644
View file @
ae777ea0
module
Gitlab
module
ImportExport
class
Importer
include
Gitlab
::
ImportExport
::
CommandLineUtil
def
self
.
import
(
*
args
)
new
(
*
args
).
import
end
def
initialize
(
archive_file
:,
storage_path
:)
@archive_file
=
archive_file
@storage_path
=
storage_path
end
def
import
decompress_export
end
private
def
decompress
untar_czf
(
archive:
archive_file
,
dir:
@storage_path
)
end
end
end
end
lib/gitlab/import_export/repo_restorer.rb
0 → 100644
View file @
ae777ea0
module
Gitlab
module
ImportExport
class
RepoRestorer
include
Gitlab
::
ImportExport
::
CommandLineUtil
def
initialize
(
project:
,
path:
)
@project
=
project
@path
=
path
end
def
restore
return
false
unless
File
.
exists?
(
@path
)
# Move repos dir to 'repositories.old' dir
FileUtils
.
mkdir_p
(
repos_path
)
FileUtils
.
mkdir_p
(
path_to_repo
)
untar_cf
(
archive:
@path
,
dir:
path_to_repo
)
end
private
def
repos_path
Gitlab
.
config
.
gitlab_shell
.
repos_path
end
def
path_to_repo
@project
.
repository
.
path_to_repo
end
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