Sha256: adea0a7830ec566589d85a338c7841d6e0fc848b3dfa7db0d14e881cb8d68306

Contents?: true

Size: 729 Bytes

Versions: 1

Compression:

Stored size: 729 Bytes

Contents

# For more info see: https://github.com/schacon/ruby-git

require 'git'

module Danger
  class GitRepo
    attr_accessor :diff

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

    def exec(string)
      `git #{string}`.strip
    end

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

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

    def modified_files
      @diff.stats[:files].keys
    end

    def lines_of_code
      @diff.lines
    end

    def deletions
      @diff.deletions
    end

    def insertions
      @diff.insertions
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-0.6.5 lib/danger/scm_source/git_repo.rb