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
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
nexedi
gitlab-shell
Commits
047dcb86
Commit
047dcb86
authored
Apr 16, 2013
by
Angus MacArthur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
additional fork check and enhanced tests
parent
934aacb3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
lib/gitlab_projects.rb
lib/gitlab_projects.rb
+5
-0
spec/gitlab_projects_spec.rb
spec/gitlab_projects_spec.rb
+17
-6
No files found.
lib/gitlab_projects.rb
View file @
047dcb86
...
...
@@ -86,11 +86,16 @@ class GitlabProjects
def
fork_project
new_namespace
=
ARGV
.
shift
# destination namespace must be provided
return
false
unless
new_namespace
#destination namespace must exist
namespaced_path
=
File
.
join
(
repos_path
,
new_namespace
)
return
false
unless
File
.
exists?
(
namespaced_path
)
#a project of the same name cannot already be within the destination namespace
full_destination_path
=
File
.
join
(
namespaced_path
,
project_name
)
return
false
if
File
.
exists?
(
full_destination_path
)
cmd
=
"cd
#{
namespaced_path
}
&& git clone --bare
#{
full_path
}
&&
#{
create_hooks_to
(
full_destination_path
)
}
"
system
(
cmd
)
...
...
spec/gitlab_projects_spec.rb
View file @
047dcb86
...
...
@@ -79,19 +79,30 @@ describe GitlabProjects do
describe
:fork_project
do
let
(
:gl_project_import
)
{
build_gitlab_projects
(
'import-project'
,
repo_name
,
'https://github.com/randx/six.git'
)
}
let
(
:gl_projects
)
{
build_gitlab_projects
(
'fork-project'
,
repo_name
,
'forked-to-namespace'
)}
let
(
:gl_projects_fork
)
{
build_gitlab_projects
(
'fork-project'
,
repo_name
,
'forked-to-namespace'
)}
let
(
:dest_repo
)
{
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
,
repo_name
)
}
before
do
FileUtils
.
mkdir_p
(
tmp_repo_path
)
FileUtils
.
mkdir_p
(
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
))
gl_project_import
.
exec
end
it
"should not fork into a namespace that doesn't exist"
do
gl_projects_fork
.
exec
.
should
be_false
end
it
"should fork the repo"
do
gl_projects
.
exec
File
.
exists?
(
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
,
repo_name
)).
should
be_true
File
.
exists?
(
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
,
repo_name
,
'/hooks/update'
)).
should
be_true
File
.
exists?
(
File
.
join
(
tmp_repos_path
,
'forked-to-namespace'
,
repo_name
,
'/hooks/post-receive'
)).
should
be_true
# create destination namespace
FileUtils
.
mkdir_p
(
File
.
join
(
tmp_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/update'
)).
should
be_true
File
.
exists?
(
File
.
join
(
dest_repo
,
'/hooks/post-receive'
)).
should
be_true
end
it
"should not fork if a project of the same name already exists"
do
#trying to fork again should fail as the repo already exists
gl_projects_fork
.
exec
.
should
be_false
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