module YAVDB::Utils::Git
Public Class Methods
download_or_update(repo_path, repo_url, repo_branch, force_update = true)
click to toggle source
# File lib/yavdb/utils/git.rb, line 42 def self.download_or_update(repo_path, repo_url, repo_branch, force_update = true) puts "Downloading #{repo_url}" if Constants::DEBUG if File.exist?(repo_path) && Dir.entries(repo_path) != ['.', '..'] if File.directory?(File.expand_path(File.join(repo_path, '.git'))) Dir.chdir(repo_path) do YAVDB::Utils::Executor.run("git fetch --all && git reset --hard origin/#{repo_branch}") if force_update end else puts "Repository directory already exists and is not a valid git repository in #{repo_path}" exit(1) end else YAVDB::Utils::Executor.run("git clone #{repo_url} -b #{repo_branch} #{repo_path}") end end
get_contents(repo_url, repo_branch, with_cache = true, group_cache_key = 'git')
click to toggle source
# File lib/yavdb/utils/git.rb, line 27 def self.get_contents(repo_url, repo_branch, with_cache = true, group_cache_key = 'git') puts "Requesting #{repo_url}" if Constants::DEBUG if with_cache YAVDB::Utils::Cache.cache_path(group_cache_key, repo_url) do |repo_path| download_or_update(repo_path, repo_url, repo_branch) repo_path end else repo_path = Dir.mktmpdir(group_cache_key) download_or_update(repo_path, repo_url, repo_branch) repo_path end end