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
Boxiang Sun
gitlab-ce
Commits
92f4bde4
Commit
92f4bde4
authored
May 05, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use git bundle in import and add wiki repo to import
parent
43488d27
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
lib/gitlab/import_export/command_line_util.rb
lib/gitlab/import_export/command_line_util.rb
+6
-0
lib/gitlab/import_export/import_service.rb
lib/gitlab/import_export/import_service.rb
+14
-2
lib/gitlab/import_export/repo_restorer.rb
lib/gitlab/import_export/repo_restorer.rb
+5
-6
No files found.
lib/gitlab/import_export/command_line_util.rb
View file @
92f4bde4
...
@@ -23,6 +23,12 @@ module Gitlab
...
@@ -23,6 +23,12 @@ module Gitlab
status
.
zero?
status
.
zero?
end
end
def
git_unbundle
(
git_bin_path:
Gitlab
.
config
.
git
.
bin_path
,
repo_path
:,
bundle_path
:)
cmd
=
%W(
#{
git_bin_path
}
clone --bare
#{
bundle_path
}
#{
repo_path
}
)
_output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
status
.
zero?
end
def
tar_with_options
(
archive
:,
dir
:,
options
:)
def
tar_with_options
(
archive
:,
dir
:,
options
:)
cmd
=
%W(tar -
#{
options
}
#{
archive
}
-C
#{
dir
}
.)
cmd
=
%W(tar -
#{
options
}
#{
archive
}
-C
#{
dir
}
.)
_output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
_output
,
status
=
Gitlab
::
Popen
.
popen
(
cmd
)
...
...
lib/gitlab/import_export/import_service.rb
View file @
92f4bde4
...
@@ -15,7 +15,7 @@ module Gitlab
...
@@ -15,7 +15,7 @@ module Gitlab
def
execute
def
execute
Gitlab
::
ImportExport
::
Importer
.
import
(
archive_file:
@archive_file
,
storage_path:
storage_path
)
Gitlab
::
ImportExport
::
Importer
.
import
(
archive_file:
@archive_file
,
storage_path:
storage_path
)
project_tree
.
project
if
[
restore_project_tree
,
restore_repo
].
all?
project_tree
.
project
if
[
restore_project_tree
,
restore_repo
,
restore_wiki_repo
].
all?
end
end
private
private
...
@@ -29,7 +29,11 @@ module Gitlab
...
@@ -29,7 +29,11 @@ module Gitlab
end
end
def
restore_repo
def
restore_repo
Gitlab
::
ImportExport
::
RepoRestorer
.
new
(
path:
storage_path
,
project:
project_tree
.
project
).
restore
Gitlab
::
ImportExport
::
RepoRestorer
.
new
(
path:
repo_path
,
project:
project_tree
.
project
).
restore
end
def
restore_wiki_repo
Gitlab
::
ImportExport
::
RepoRestorer
.
new
(
path:
wiki_repo_path
,
project:
project_tree
.
project
).
restore
end
end
def
storage_path
def
storage_path
...
@@ -39,6 +43,14 @@ module Gitlab
...
@@ -39,6 +43,14 @@ module Gitlab
def
path_with_namespace
def
path_with_namespace
File
.
join
(
@namespace
.
path
,
@project_path
)
File
.
join
(
@namespace
.
path
,
@project_path
)
end
end
def
repo_path
File
.
join
(
'storage_path'
,
'project.bundle'
)
end
def
wiki_repo_path
File
.
join
(
'storage_path'
,
'project.wiki.bundle'
)
end
end
end
end
end
end
end
lib/gitlab/import_export/repo_restorer.rb
View file @
92f4bde4
...
@@ -3,19 +3,18 @@ module Gitlab
...
@@ -3,19 +3,18 @@ module Gitlab
class
RepoRestorer
class
RepoRestorer
include
Gitlab
::
ImportExport
::
CommandLineUtil
include
Gitlab
::
ImportExport
::
CommandLineUtil
def
initialize
(
project
:,
path
:
)
def
initialize
(
project
:,
path
_to_bundle:
)
@project
=
project
@project
=
project
# TODO remove magic keyword and move it to a shared config
@path_to_bundle
=
path_to_bundle
@path
=
File
.
join
(
path
,
'project.bundle'
)
end
end
def
restore
def
restore
return
false
unless
File
.
exists?
(
@path
)
return
true
unless
File
.
exists?
(
@path
)
# Move repos dir to 'repositories.old' dir
FileUtils
.
mkdir_p
(
repos_path
)
FileUtils
.
mkdir_p
(
repos_path
)
FileUtils
.
mkdir_p
(
path_to_repo
)
FileUtils
.
mkdir_p
(
path_to_repo
)
untar_xf
(
archive:
@path
,
dir:
path_to_repo
)
git_unbundle
(
git_bin_path:
Gitlab
.
config
.
git
.
bin_path
,
repo_path:
path_to_repo
,
bundle_path:
@path_to_bundle
)
end
end
private
private
...
...
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