Class: Gitl::Init

Inherits:
SubCommand show all
Defined in:
lib/commands/init.rb

Instance Attribute Summary

Attributes inherited from SubCommand

#gitl_config

Instance Method Summary collapse

Methods inherited from SubCommand

#check_uncommit, #initialize, options, #run_in_workspace, #save_workspace_config, #validate!, #workspace_config

Methods inherited from Command

#error, handle_exception, #info, report_error, run

Constructor Details

This class inherits a constructor from Gitl::SubCommand

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/commands/init.rb', line 13

def run
  mutex = Mutex.new
  threads = []
  self.gitl_config.projects.each do |project|
    t = Thread.new do
      project_path = File.expand_path(project.name, './')
      if File.exist?(project_path)
        mutex.synchronize do
          info project.name + ' exists, skip.'
        end
      else
        Git.clone_without_env(project.git, project.name, :path => './')
      end
    end
    threads << t
  end
  threads.each do |t| 
    t.join
  end
  puts "#{self.gitl_config.projects.size} projects init success.".green
end