Sha256: fcd5e6c0b838b4a16f2e8d2f6f7e485cfcbd29ed4a3e7fc1874c9934d0202cfd

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

require "tmpdir"

module RakeHelper
  include Rfix::Log
  include Rfix::Cmd
  include Rfix::GitHelper

  def dirty?
    !cmd_succeeded?("git diff --quiet")
  end

  def clone(github:, ref:)
    Dir.mktmpdir(github.split("/")) do |src|
      say "Clone {{info:#{github}}}, hold on ..."
      git("clone", "https://github.com/#{github}", src)
      Dir.chdir(src) do
        say "Check out {{info:#{ref}}}"
        git("reset", "--hard", ref)
        git("clean", "-f", "-d")
      end

      dest = File.join("vendor", github)
      say "Copy files to {{info:#{dest}}}"
      FileUtils.mkdir_p(dest)
      FileUtils.copy_entry(src, dest, true, true, true)
    end
  end

  def gemfiles
    Dir.glob("ci/Gemfile*").unshift("Gemfile").reject do |path|
      [".lock", ".base"].include?(File.extname(path))
    end
  end

  def gemlocks
    Dir.glob("ci/Gemfile*.lock").unshift("Gemfile.lock")
  end

  def source_for(name:)
    bundle_root = Bundler.bundle_path.join('bundler/gems')
    path = Dir.glob(bundle_root.join("#{name}-*").to_s).first
    path or raise "Could not find source for #{name}, run bundle install first"
  end

  def dest_for(name:)
    File.join(__dir__, 'vendor', name)
  end

  def osx?
    ENV.fetch("TRAVIS_OS_NAME") == "osx"
  end

  def brew_url(ref:)
    "https://raw.githubusercontent.com/Homebrew/homebrew-core/#{ref}/Formula/git.rb"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rfix-1.0.15.pre.116 lib/rfix/rake_helper.rb
rfix-1.0.15 lib/rfix/rake_helper.rb
rfix-1.0.8.pre.109 lib/rfix/rake_helper.rb
rfix-1.0.8.pre.108 lib/rfix/rake_helper.rb