Sha256: 65c63f69275d0c178bbca4e9b8d32569a97875d43cbf234da2ddf18e2a510ec6
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
require "danger/ci_source/ci_source" require "danger/request_sources/request_source" module Danger class EnvironmentManager attr_accessor :ci_source, :request_source, :scm # Finds a Danger::CI class based on the ENV def self.local_ci_source(env) CI.available_ci_sources.find { |ci| ci.validates_as_ci? env } end # Uses the current Danger::CI subclass, and sees if it is a PR def self.pr?(env) local_ci_source(env).validates_as_pr?(env) end def initialize(env) ci_klass = self.class.local_ci_source(env) self.ci_source = ci_klass.new(env) RequestSources::RequestSource.available_request_sources.each do |klass| next unless self.ci_source.supports?(klass) request_source = klass.new(self.ci_source, env) next unless request_source.validates_as_ci? next unless request_source.validates_as_api_source? self.request_source = request_source end raise "Could not find a Request Source for #{ci_klass}\nCI: #{ci_source.inspect}".red unless self.request_source self.scm = self.request_source.scm end def pr? self.ci_source != nil end def fill_environment_vars request_source.fetch_details end def ensure_danger_branches_are_setup clean_up self.request_source.setup_danger_branches end def clean_up [EnvironmentManager.danger_base_branch, EnvironmentManager.danger_head_branch].each do |branch| scm.exec("branch -D #{branch}") unless scm.exec("rev-parse --quiet --verify #{branch}").empty? end end def meta_info_for_base scm.exec("--no-pager log #{EnvironmentManager.danger_base_branch} -n1") end def meta_info_for_head scm.exec("--no-pager log #{EnvironmentManager.danger_head_branch} -n1") end def self.danger_head_branch "danger_head" end def self.danger_base_branch "danger_base" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
danger-3.3.2 | lib/danger/danger_core/environment_manager.rb |
danger-3.3.1 | lib/danger/danger_core/environment_manager.rb |