Sha256: 2f3c3da59e953c47e5a32ce473b0c1c228db140929316c08c887c0388e356889

Contents?: true

Size: 645 Bytes

Versions: 3

Compression:

Stored size: 645 Bytes

Contents

# https://github.com/schacon/ruby-git

require 'git'

module Danger
  class GitRepo
    attr_accessor :diff

    def diff_for_folder(folder, from = "HEAD", to = 'master')
      g = Git.open(folder)
      self.diff = g.diff(to, from)
    end

    def files_modified
      @diff.to_a.map(&:path)
    end

    def files_removed
      @diff.to_a.select { |d| d.type == "deleted" }.map(&:path)
    end

    def files_added
      @diff.to_a.select { |d| d.type == "new" }.map(&:path)
    end

    def lines_of_code
      @diff.lines
    end

    def deletions
      @diff.deletions
    end

    def insertions
      @diff.insertions
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
danger-0.2.1 lib/danger/scm_source/git_repo.rb
danger-0.2.0 lib/danger/scm_source/git_repo.rb
danger-0.1.1 lib/danger/scm_source/git_repo.rb