lib/danger/ci_source/circle.rb in danger-0.8.1 vs lib/danger/ci_source/circle.rb in danger-0.8.2
- old
+ new
@@ -4,16 +4,22 @@
module Danger
module CISource
class CircleCI < CI
def self.validates?(env)
- return false if env["CIRCLE_BUILD_NUM"].nil?
- return true unless env["CI_PULL_REQUEST"].nil?
+ return false unless env["CIRCLE_BUILD_NUM"]
+ return false unless env["CI_PULL_REQUEST"]
+ return false unless env["CIRCLE_PROJECT_USERNAME"]
+ return false unless env["CIRCLE_PROJECT_REPONAME"]
- return !env["CIRCLE_PROJECT_USERNAME"].nil? && !env["CIRCLE_PROJECT_REPONAME"].nil?
+ return true
end
+ def supported_request_sources
+ @supported_request_sources ||= [Danger::RequestSources::GitHub]
+ end
+
def client
@client ||= CircleAPI.new(@circle_token)
end
def fetch_pull_request_url(repo_slug, build_number)
@@ -31,9 +37,11 @@
url
end
def initialize(env)
+ self.repo_url = GitRepo.new.origins # CircleCI doesn't provide a repo url env variable :/
+
@circle_token = env["CIRCLE_CI_API_TOKEN"]
url = pull_request_url(env)
if URI.parse(url).path.split("/").count == 5
paths = URI.parse(url).path.split("/")