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
6b1129cc
Commit
6b1129cc
authored
Jul 26, 2016
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow gitlab-project's fork-project command to fork projects between different repository storages
parent
2e2af9ac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
8 deletions
+43
-8
CHANGELOG
CHANGELOG
+3
-0
lib/gitlab_projects.rb
lib/gitlab_projects.rb
+8
-1
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+32
-7
No files found.
CHANGELOG
View file @
6b1129cc
v3.2.1
- Allow gitlab-project's fork-project command to fork projects between different repository storages
v3.2.0
v3.2.0
- Allow GitLab Shell to check for allowed access based on the used Git protocol
- Allow GitLab Shell to check for allowed access based on the used Git protocol
- Add an error message when using shell commands with incompatible GitLab versions
- Add an error message when using shell commands with incompatible GitLab versions
...
...
lib/gitlab_projects.rb
View file @
6b1129cc
...
@@ -286,6 +286,13 @@ class GitlabProjects
...
@@ -286,6 +286,13 @@ class GitlabProjects
end
end
def
fork_project
def
fork_project
destination_repos_path
=
ARGV
.
shift
unless
destination_repos_path
$logger
.
error
"fork-project failed: no destination repository path provided."
return
false
end
new_namespace
=
ARGV
.
shift
new_namespace
=
ARGV
.
shift
# destination namespace must be provided
# destination namespace must be provided
...
@@ -295,7 +302,7 @@ class GitlabProjects
...
@@ -295,7 +302,7 @@ class GitlabProjects
end
end
# destination namespace must exist
# destination namespace must exist
namespaced_path
=
File
.
join
(
repos_path
,
new_namespace
)
namespaced_path
=
File
.
join
(
destination_
repos_path
,
new_namespace
)
unless
File
.
exists?
(
namespaced_path
)
unless
File
.
exists?
(
namespaced_path
)
$logger
.
error
"fork-project failed: destination namespace <
#{
namespaced_path
}
> does not exist."
$logger
.
error
"fork-project failed: destination namespace <
#{
namespaced_path
}
> does not exist."
return
false
return
false
...
...
spec/gitlab_projects_spec.rb
View file @
6b1129cc
...
@@ -3,7 +3,6 @@ require_relative '../lib/gitlab_projects'
...
@@ -3,7 +3,6 @@ require_relative '../lib/gitlab_projects'
describe
GitlabProjects
do
describe
GitlabProjects
do
before
do
before
do
GitlabConfig
.
any_instance
.
stub
(
repos_path:
tmp_repos_path
)
FileUtils
.
mkdir_p
(
tmp_repos_path
)
FileUtils
.
mkdir_p
(
tmp_repos_path
)
$logger
=
double
(
'logger'
).
as_null_object
$logger
=
double
(
'logger'
).
as_null_object
end
end
...
@@ -254,15 +253,21 @@ describe GitlabProjects do
...
@@ -254,15 +253,21 @@ describe GitlabProjects do
describe
:fork_project
do
describe
:fork_project
do
let
(
:source_repo_name
)
{
File
.
join
(
'source-namespace'
,
repo_name
)
}
let
(
:source_repo_name
)
{
File
.
join
(
'source-namespace'
,
repo_name
)
}
let
(
:dest_repo
)
{
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
,
repo_name
)
}
let
(
:dest_repo
)
{
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
,
repo_name
)
}
let
(
:gl_projects_fork
)
{
build_gitlab_projects
(
'fork-project'
,
tmp_repos_path
,
source_repo_name
,
'forked-to-namespace'
)
}
let
(
:gl_projects_fork
)
{
build_gitlab_projects
(
'fork-project'
,
tmp_repos_path
,
source_repo_name
,
tmp_repos_path
,
'forked-to-namespace'
)
}
let
(
:gl_projects_import
)
{
build_gitlab_projects
(
'import-project'
,
tmp_repos_path
,
source_repo_name
,
'https://github.com/randx/six.git'
)
}
let
(
:gl_projects_import
)
{
build_gitlab_projects
(
'import-project'
,
tmp_repos_path
,
source_repo_name
,
'https://github.com/randx/six.git'
)
}
before
do
before
do
gl_projects_import
.
exec
gl_projects_import
.
exec
end
end
it
"should not fork without a
destination namespace
"
do
it
"should not fork without a
source repository path
"
do
missing_arg
=
build_gitlab_projects
(
'fork-project'
,
tmp_repos_path
,
source_repo_name
)
missing_arg
=
build_gitlab_projects
(
'fork-project'
,
tmp_repos_path
,
source_repo_name
)
$logger
.
should_receive
(
:error
).
with
(
"fork-project failed: no destination repository path provided."
)
missing_arg
.
exec
.
should
be_false
end
it
"should not fork without a destination namespace"
do
missing_arg
=
build_gitlab_projects
(
'fork-project'
,
tmp_repos_path
,
source_repo_name
,
tmp_repos_path
)
$logger
.
should_receive
(
:error
).
with
(
"fork-project failed: no destination namespace provided."
)
$logger
.
should_receive
(
:error
).
with
(
"fork-project failed: no destination namespace provided."
)
missing_arg
.
exec
.
should
be_false
missing_arg
.
exec
.
should
be_false
end
end
...
@@ -301,6 +306,29 @@ describe GitlabProjects do
...
@@ -301,6 +306,29 @@ describe GitlabProjects do
FileUtils
.
mkdir_p
(
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
))
FileUtils
.
mkdir_p
(
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
))
gl_projects_fork
.
exec
.
should
be_true
gl_projects_fork
.
exec
.
should
be_true
end
end
context
'different storages'
do
let
(
:alternative_repos_path
)
{
File
.
join
(
ROOT_PATH
,
'tmp'
,
'alternative'
)
}
let
(
:dest_repo
)
{
File
.
join
(
alternative_repos_path
,
'forked-to-namespace'
,
repo_name
)
}
let
(
:gl_projects_fork
)
{
build_gitlab_projects
(
'fork-project'
,
tmp_repos_path
,
source_repo_name
,
alternative_repos_path
,
'forked-to-namespace'
)
}
before
do
FileUtils
.
mkdir_p
(
alternative_repos_path
)
end
after
do
FileUtils
.
rm_rf
(
alternative_repos_path
)
end
it
"should fork the repo"
do
# create destination namespace
FileUtils
.
mkdir_p
(
File
.
join
(
alternative_repos_path
,
'forked-to-namespace'
))
gl_projects_fork
.
exec
.
should
be_true
File
.
exists?
(
dest_repo
).
should
be_true
File
.
exists?
(
File
.
join
(
dest_repo
,
'/hooks/pre-receive'
)).
should
be_true
File
.
exists?
(
File
.
join
(
dest_repo
,
'/hooks/post-receive'
)).
should
be_true
end
end
end
end
describe
:exec
do
describe
:exec
do
...
@@ -319,10 +347,7 @@ describe GitlabProjects do
...
@@ -319,10 +347,7 @@ describe GitlabProjects do
def
build_gitlab_projects
(
*
args
)
def
build_gitlab_projects
(
*
args
)
argv
(
*
args
)
argv
(
*
args
)
gl_projects
=
GitlabProjects
.
new
GitlabProjects
.
new
gl_projects
.
stub
(
repos_path:
tmp_repos_path
)
gl_projects
.
stub
(
full_path:
File
.
join
(
tmp_repos_path
,
gl_projects
.
project_name
))
gl_projects
end
end
def
argv
(
*
args
)
def
argv
(
*
args
)
...
...
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