class Rubtools::Tools::Git
Public Class Methods
new()
click to toggle source
# File lib/tools/git.rb, line 6 def initialize @git = which "git" @git_config = config.git raise "Add the key 'git' in the config file" unless @git_config @install_dir = @git_config.install_dir raise "Add the key install_dir: /path/to/folder" unless @install_dir raise "Git isn't installed" unless @git raise "Folder doesn't exists: #{@install_dir}" unless File.exists? @install_dir end
Public Instance Methods
clone_all()
click to toggle source
Cloning all repositories located into rubtools.yml
# File lib/tools/git.rb, line 27 def clone_all for repo in config.git.repositories clone repo end end
print_repos()
click to toggle source
Print all repositories
# File lib/tools/git.rb, line 19 def print_repos for repo in config.git.repositories success "#{repo.name}\t#{repo.url}" end end
up_all()
click to toggle source
Pull all repositories located into rubtools.yml
# File lib/tools/git.rb, line 35 def up_all for repo in config.git.repositories up repo end end
Private Instance Methods
clone(repo)
click to toggle source
Cloning a specific repository
# File lib/tools/git.rb, line 44 def clone repo repo_path = File.join @install_dir, repo.name unless File.exists? repo_path success "Cloning #{repo.name} from #{repo.url}" exec "#{@git} clone --recursive #{repo.url} #{repo_path}" do |status| success "> done" if status.success? end else success "Repository #{repo.name} already cloned" end end
up(repo)
click to toggle source
Pulling a specific repository
# File lib/tools/git.rb, line 60 def up repo repo_path = File.join @install_dir, repo.name if File.exists? repo_path success "Pulling #{repo.name} repository" exec "GIT_DIR=#{File.join(repo_path, ".git")} #{@git} pull --recurse-submodules=yes" do |status| success "> done" if status.success? end else error "Repository #{repo.name} doensn't exists" clone repo end end