diff options
-rw-r--r-- | lib/gitlab_projects.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb index 5bb92f6..1189949 100644 --- a/lib/gitlab_projects.rb +++ b/lib/gitlab_projects.rb @@ -76,14 +76,24 @@ class GitlabProjects def mv_project new_path = ARGV.shift - return false unless new_path + unless new_path + $logger.error "mv-project failed: no destination path provided." + return false + end new_full_path = File.join(repos_path, new_path) - # check if source repo exists - # and target repo does not exist - return false unless File.exists?(full_path) - return false if File.exists?(new_full_path) + # verify that the source repo exists + unless File.exists?(full_path) + $logger.error "mv-project failed: source path <#{full_path}> does not exist." + return false + end + + # ...and that the target repo does not exist + if File.exists?(new_full_path) + $logger.error "mv-project failed: destination path <#{new_full_path}> already exists." + return false + end $logger.info "Moving project #{@project_name} from <#{full_path}> to <#{new_full_path}>." FileUtils.mv(full_path, new_full_path) @@ -115,7 +125,6 @@ class GitlabProjects up_hook_path = File.join(ROOT_PATH, 'hooks', 'update') "ln -s #{pr_hook_path} #{dest_path}/hooks/post-receive && ln -s #{up_hook_path} #{dest_path}/hooks/update" - end end |