Sha256: e4699e4bd8a263a092902bc011519915660035ebd168a5ddfe399c962931bd6d
Contents?: true
Size: 1.43 KB
Versions: 9
Compression:
Stored size: 1.43 KB
Contents
module Jxedt class GitCommand def initialize(cache_path) @cache_path = File.expand_path(cache_path) prepare_cache_dir end def prepare_cache_dir FileUtils.mkdir_p(@cache_path) if @cache_path end def git(cmd, ignore_output: false, can_fail: false, git_dir: true) comps = ["git"] comps << "-C" << @cache_path if git_dir comps << cmd comps << "&> /dev/null" if ignore_output comps << "|| true" if can_fail cmd = comps.join(" ") raise "Fail to run command '#{cmd}'" unless system(cmd) end def git_clone(cmd, options = {}) git("clone #{cmd}", :git_dir => false) end def git_fetch(repo, branch) Pod::UI.puts "Fetching cache from #{repo} (branch: #{branch})".green dest_dir = @cache_path if Dir.exist?(dest_dir + "/.git") git("fetch origin #{branch}") git("checkout -f FETCH_HEAD", ignore_output: true) git("branch -D #{branch}", ignore_output: true, can_fail: true) git("checkout -b #{branch}") else FileUtils.rm_rf(dest_dir) git_clone("--depth=1 --branch=#{branch} #{repo} #{dest_dir}") end end def git_commit_and_push(branch) commit_message = "Update prebuilt cache" git("add .") git("commit -m '#{commit_message}'") git("push origin #{branch}") end end end
Version data entries
9 entries across 9 versions & 1 rubygems