lib/danger/ci_source/circle.rb in danger-5.5.0 vs lib/danger/ci_source/circle.rb in danger-5.5.1
- old
+ new
@@ -40,10 +40,11 @@
end
def self.validates_as_pr?(env)
# This will get used if it's available, instead of the API faffing.
return true if env["CI_PULL_REQUEST"] && !env["CI_PULL_REQUEST"].empty?
+ return true if env["CIRCLE_PULL_REQUEST"] && !env["CIRCLE_PULL_REQUEST"].empty?
# Real-world talk, it should be worrying if none of these are in the environment
return false unless ["CIRCLE_CI_API_TOKEN", "CIRCLE_PROJECT_USERNAME", "CIRCLE_PROJECT_REPONAME", "CIRCLE_BUILD_NUM"].all? { |x| env[x] && !env[x].empty? }
# Uses the Circle API to determine if it's a PR otherwise
@@ -55,10 +56,10 @@
@supported_request_sources ||= [Danger::RequestSources::GitHub]
end
def initialize(env)
self.repo_url = env["CIRCLE_REPOSITORY_URL"]
- pr_url = env["CI_PULL_REQUEST"]
+ pr_url = env["CI_PULL_REQUEST"] || env["CIRCLE_PULL_REQUEST"]
# If it's not a real URL, use the Circle API
unless pr_url && URI.parse(pr_url).kind_of?(URI::HTTP)
api = CircleAPI.new
pr_url = api.pull_request_url(env)