Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-shell
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-shell
Commits
522567af
Commit
522567af
authored
Jul 19, 2016
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add command to move repositories between repository storages
parent
87b38823
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
0 deletions
+72
-0
CHANGELOG
CHANGELOG
+3
-0
lib/gitlab_projects.rb
lib/gitlab_projects.rb
+32
-0
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+37
-0
No files found.
CHANGELOG
View file @
522567af
v3.3.0
- Add command to move repositories between repository storages
v3.2.1
v3.2.1
- Allow gitlab-project's fork-project command to fork projects between different repository storages
- Allow gitlab-project's fork-project command to fork projects between different repository storages
...
...
lib/gitlab_projects.rb
View file @
522567af
...
@@ -55,6 +55,7 @@ class GitlabProjects
...
@@ -55,6 +55,7 @@ class GitlabProjects
when
'list-projects'
;
puts
list_projects
when
'list-projects'
;
puts
list_projects
when
'rm-project'
;
rm_project
when
'rm-project'
;
rm_project
when
'mv-project'
;
mv_project
when
'mv-project'
;
mv_project
when
'mv-storage'
;
mv_storage
when
'import-project'
;
import_project
when
'import-project'
;
import_project
when
'fork-project'
;
fork_project
when
'fork-project'
;
fork_project
when
'fetch-remote'
;
fetch_remote
when
'fetch-remote'
;
fetch_remote
...
@@ -285,6 +286,37 @@ class GitlabProjects
...
@@ -285,6 +286,37 @@ class GitlabProjects
FileUtils
.
mv
(
full_path
,
new_full_path
)
FileUtils
.
mv
(
full_path
,
new_full_path
)
end
end
# Move repository from one storage path to another
#
# Wont work if target namespace directory does not exist in the new storage path
#
def
mv_storage
new_storage
=
ARGV
.
shift
unless
new_storage
$logger
.
error
"mv-storage failed: no destination storage path provided."
return
false
end
new_full_path
=
File
.
join
(
new_storage
,
project_name
)
# verify that the source repo exists
unless
File
.
exists?
(
full_path
)
$logger
.
error
"mv-storage failed: source path <
#{
full_path
}
> does not exist."
return
false
end
# Make sure the destination directory exists
FileUtils
.
mkdir_p
(
new_full_path
)
# Make sure the source path ends with a slash so that rsync copies the
# contents of the directory, as opposed to copying the directory by name
source_path
=
File
.
join
(
full_path
,
''
)
$logger
.
info
"Syncing project
#{
@project_name
}
from <
#{
full_path
}
> to <
#{
new_full_path
}
>."
system
(
*
%W(rsync -a
#{
source_path
}
#{
new_full_path
}
)
)
end
def
fork_project
def
fork_project
destination_repos_path
=
ARGV
.
shift
destination_repos_path
=
ARGV
.
shift
...
...
spec/gitlab_projects_spec.rb
View file @
522567af
...
@@ -205,6 +205,43 @@ describe GitlabProjects do
...
@@ -205,6 +205,43 @@ describe GitlabProjects do
end
end
end
end
describe
:mv_storage
do
let
(
:alternative_storage_path
)
{
File
.
join
(
ROOT_PATH
,
'tmp'
,
'alternative'
)
}
let
(
:gl_projects
)
{
build_gitlab_projects
(
'mv-storage'
,
tmp_repos_path
,
repo_name
,
alternative_storage_path
)
}
let
(
:new_repo_path
)
{
File
.
join
(
alternative_storage_path
,
repo_name
)
}
before
do
FileUtils
.
mkdir_p
(
tmp_repo_path
)
FileUtils
.
mkdir_p
(
alternative_storage_path
)
end
after
{
FileUtils
.
rm_rf
(
alternative_storage_path
)
}
it
"should rsync a repo directory"
do
File
.
exists?
(
tmp_repo_path
).
should
be_true
gl_projects
.
exec
File
.
exists?
(
new_repo_path
).
should
be_true
end
it
"should fail if no destination path is provided"
do
incomplete
=
build_gitlab_projects
(
'mv-storage'
,
tmp_repos_path
,
repo_name
)
$logger
.
should_receive
(
:error
).
with
(
"mv-storage failed: no destination storage path provided."
)
incomplete
.
exec
.
should
be_false
end
it
"should fail if the source path doesn't exist"
do
bad_source
=
build_gitlab_projects
(
'mv-storage'
,
tmp_repos_path
,
'bad-src.git'
,
alternative_storage_path
)
$logger
.
should_receive
(
:error
).
with
(
"mv-storage failed: source path <
#{
tmp_repos_path
}
/bad-src.git> does not exist."
)
bad_source
.
exec
.
should
be_false
end
it
"should log an mv-storage event"
do
message
=
"Syncing project
#{
repo_name
}
from <
#{
tmp_repo_path
}
> to <
#{
new_repo_path
}
>."
$logger
.
should_receive
(
:info
).
with
(
message
)
gl_projects
.
exec
end
end
describe
:import_project
do
describe
:import_project
do
context
'success import'
do
context
'success import'
do
let
(
:gl_projects
)
{
build_gitlab_projects
(
'import-project'
,
tmp_repos_path
,
repo_name
,
'https://github.com/randx/six.git'
)
}
let
(
:gl_projects
)
{
build_gitlab_projects
(
'import-project'
,
tmp_repos_path
,
repo_name
,
'https://github.com/randx/six.git'
)
}
...
...
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