Sha256: b7a301fb8de0b279e466a6f7944dd435843bd0ea4275664bb949e953f433aa44
Contents?: true
Size: 1.47 KB
Versions: 1
Compression:
Stored size: 1.47 KB
Contents
# For more info see: https://github.com/schacon/ruby-git require "git" require "uri" require "danger/ci_source/support/remote_finder" require "danger/ci_source/support/merged_pull_request_finder" require "danger/request_sources/github" module Danger # ignore class LocalGitRepo < CI attr_accessor :base_commit, :head_commit def self.validates_as_ci?(env) env.key? "DANGER_USE_LOCAL_GIT" end def self.validates_as_pr?(_env) false end def git @git ||= GitRepo.new end def run_git(command) git.exec command end def supported_request_sources @supported_request_sources ||= [Danger::RequestSources::GitHub] end def print_repo_slug_warning puts "Danger local requires a repository hosted on GitHub.com or GitHub Enterprise.".freeze end def parents(sha) @parents ||= run_git("rev-list --parents -n 1 #{sha}").strip.split(" ".freeze) end def initialize(env = {}) repo_slug = RemoteFinder.new( env["DANGER_GITHUB_HOST"] || "github.com".freeze, run_git("remote show origin -n".freeze) ).call pull_request_id, sha = MergedPullRequestFinder.new( env["LOCAL_GIT_PR_ID"] || "", run_git("log --oneline -1000000".freeze) ).call self.repo_slug = repo_slug ? repo_slug : print_repo_slug_warning self.pull_request_id = pull_request_id self.base_commit = parents(sha)[0] self.head_commit = parents(sha)[1] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
danger-3.3.2 | lib/danger/ci_source/local_git_repo.rb |