diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab_projects.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb index a0063aa..d761026 100644 --- a/lib/gitlab_projects.rb +++ b/lib/gitlab_projects.rb @@ -1,4 +1,5 @@ require 'fileutils' +require 'timeout' require_relative 'gitlab_config' require_relative 'gitlab_logger' @@ -92,9 +93,23 @@ class GitlabProjects # URL must be publicly cloneable def import_project @source = ARGV.shift + + # timeout for clone + timeout = (ARGV.shift || 120).to_i $logger.info "Importing project #{@project_name} from <#{@source}> to <#{full_path}>." cmd = %W(git clone --bare -- #{@source} #{full_path}) - system(*cmd) && self.class.create_hooks(full_path) + + begin + Timeout.timeout(timeout) do + system(*cmd) + end + rescue + $logger.error "Importing project #{@project_name} from <#{@source}> failed due to timeout." + FileUtils.rm_rf(full_path) + false + else + self.class.create_hooks(full_path) + end end # Move repository from one directory to another |
