Sha256: d9f5bd64da053bd987b2d75ae03e5d40131567f14148524976a776a0dc6e0cc5

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

require 'rugged'
require_relative 'rugged/diff'
require_relative 'rugged/tree'
require_relative 'rugged/diff/delta'

require 'pronto/plugin'
require 'pronto/message'
require 'pronto/runner'

require 'pronto/formatter/text_formatter'

module Pronto
  def self.run(commit1 = nil, commit2 = 'master', repo_path = '.')
    patches = diff(repo_path, commit1, commit2)
    result = run_all_runners(patches)
    Formatter::TextFormatter.new.format(result)
  end

  def self.gem_names
    gems = Gem::Specification.find_all.select do |gem|
      if gem.name =~ /^pronto-/
        true
      elsif gem.name != 'pronto'
        runner_path = File.join(gem.full_gem_path, "lib/pronto/#{gem.name}.rb")
        File.exists?(runner_path)
      end
    end

    gems.map { |gem| gem.name.sub(/^pronto-/, '') }
        .uniq
        .sort
  end

  private

  def self.diff(repo_path, commit1, commit2)
    repo = Rugged::Repository.new(repo_path)
    commit1 ||= repo.head.target
    commit2 ||= 'master'
    repo.diff(commit1, commit2)
  end

  def self.run_all_runners(patches)
    Runner.runners.map do |runner|
      runner.new.run(patches)
    end.flatten.compact
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pronto-0.0.2 lib/pronto.rb