Sha256: de1335aebb4e67d56516ba21f82e44a26a923da1642ddd7058bcfdd2ed6f3163

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require 'fileutils'

require 'grit'

require 'vendorificator/vendor'

class Vendorificator::Vendor::Git < Vendorificator::Vendor
  arg_reader :repository, :revision, :branch
  attr_reader :module_repo, :conjured_revision

  def initialize(name, args={}, &block)
    unless args.include?(:repository)
      args[:repository] = name
      name = name.split('/').last.sub(/\.git$/, '')
    end
    super(name, args, &block)
  end

  def conjure!
    shell.say_status :clone, repository
    Grit::Git.new('.').clone({}, repository, '.')
    @module_repo = Grit::Repo.new('.')

    if revision
      module_repo.git.checkout({:b => 'vendorified'}, revision)
    elsif branch
      module_repo.git.checkout({:b => 'vendorified'}, "origin/#{branch}")
    end

    super
    @conjured_revision = module_repo.head.commit.id
    FileUtils::rm_rf '.git'
  end

  def upstream_version
    conjured_revision
  end

  def conjure_commit_message
    rv = "Conjured git module #{name} "
    rv << "version #{version} " if version
    rv << "revision #{conjured_revision}"
    rv
  end

  install!
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vendorificator-0.1.1 lib/vendorificator/vendor/git.rb
vendorificator-0.1.0 lib/vendorificator/vendor/git.rb
vendorificator-0.0.1 lib/vendorificator/vendor/git.rb