summaryrefslogtreecommitdiff
path: root/lib/gitlab_projects.rb
diff options
context:
space:
mode:
authorAngus MacArthur <amacarthur@blackberry.com>2013-04-16 11:56:39 -0400
committerAngus MacArthur <amacarthur@blackberry.com>2013-04-16 12:12:40 -0400
commit047dcb86af85a4f1a56cf34baff036af1aa3c222 (patch)
tree9506a2962af8df423aab4492af436fa5dd7d2c6c /lib/gitlab_projects.rb
parent934aacb34ba65cd47ce8fefd4cad64c4a3951856 (diff)
downloadgitlab-shell-047dcb86af85a4f1a56cf34baff036af1aa3c222.tar.gz
additional fork check and enhanced tests
Diffstat (limited to 'lib/gitlab_projects.rb')
-rw-r--r--lib/gitlab_projects.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
index 154ada1..1c2128e 100644
--- a/lib/gitlab_projects.rb
+++ b/lib/gitlab_projects.rb
@@ -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)