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
a471d552
Commit
a471d552
authored
Mar 28, 2013
by
Angus MacArthur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fork_project command
parent
8e75018c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
lib/gitlab_projects.rb
lib/gitlab_projects.rb
+13
-0
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+12
-1
No files found.
lib/gitlab_projects.rb
View file @
a471d552
...
...
@@ -29,6 +29,7 @@ class GitlabProjects
when
'rm-project'
;
rm_project
when
'mv-project'
;
mv_project
when
'import-project'
;
import_project
when
'fork-project'
;
fork_project
else
puts
'not allowed'
false
...
...
@@ -84,4 +85,16 @@ class GitlabProjects
FileUtils
.
mv
(
full_path
,
new_full_path
)
end
def
fork_project
new_namespace
=
ARGV
.
shift
return
false
unless
new_namespace
namespaced_path
=
File
.
join
(
repos_path
,
new_namespace
)
return
false
unless
File
.
exists?
(
namespaced_path
)
cmd
=
"cd
#{
namespaced_path
}
&& git clone --bare
#{
@full_path
}
"
system
(
cmd
)
end
end
spec/gitlab_projects_spec.rb
View file @
a471d552
...
...
@@ -18,7 +18,7 @@ describe GitlabProjects do
it
{
@gl_projects
.
project_name
.
should
==
repo_name
}
it
{
@gl_projects
.
instance_variable_get
(
:@command
).
should
==
'add-project'
}
it
{
@gl_projects
.
instance_variable_get
(
:@full_path
).
should
==
'/home/git/repositories/gitlab-ci.git'
}
it
{
@gl_projects
.
instance_variable_get
(
:@full_path
).
should
==
"
#{
GitlabConfig
.
new
.
repos_path
}
/gitlab-ci.git"
}
end
describe
:add_project
do
...
...
@@ -77,6 +77,17 @@ describe GitlabProjects do
end
end
describe
:fork_project
do
let
(
:gl_projects
)
{
build_gitlab_projects
(
'fork-project'
,
repo_name
,
'forked-to-namespace'
)}
it
"should fork the repo"
do
gl_projects
.
exec
File
.
exists?
(
File
.
join
(
tmp_repo_path
,
'forked-to-namespace'
,
repo_name
))
File
.
exists?
(
File
.
join
(
tmp_repo_path
,
'forked-to-namespace'
,
repo_name
,
'/hooks/update/post-receive'
))
File
.
exists?
(
File
.
join
(
tmp_repo_path
,
'forked-to-namespace'
,
repo_name
,
'/hooks/update/'
))
end
end
describe
:exec
do
it
'should puts message if unknown command arg'
do
gitlab_projects
=
build_gitlab_projects
(
'edit-project'
,
repo_name
)
...
...
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