Sha256: bea134def92f26153c073dcda6d71ed1611478a80bd20524e1cbc1d118dd90e0
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
# For more info see: https://github.com/schacon/ruby-git require "git" module Danger class GitRepo attr_accessor :diff, :log def diff_for_folder(folder, from: "master", to: "HEAD") repo = Git.open folder merge_base = repo.merge_base(from, to) self.diff = repo.diff(merge_base.to_s, to) self.log = repo.log.between(from, to) end def exec(string) `git #{string}`.strip end def head_commit exec "rev-parse HEAD" end def origins exec("remote show origin -n").lines.grep(/Fetch URL/)[0].split(": ", 2)[1].chomp end end end # For full context see: # https://github.com/danger/danger/issues/160 # and https://github.com/danger/danger/issues/316 # # for which the fix comes from an unmerged PR from 2012 # https://github.com/schacon/ruby-git/pull/43 module Git class Base def merge_base(commit1, commit2, *other_commits) Git::Object.new self, self.lib.merge_base(commit1, commit2, *other_commits) end end class Lib def merge_base(commit1, commit2, *other_commits) arr_opts = [] arr_opts << commit1 arr_opts << commit2 arr_opts += other_commits command("merge-base", arr_opts) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
danger-3.1.1 | lib/danger/scm_source/git_repo.rb |
danger-3.1.0 | lib/danger/scm_source/git_repo.rb |