Sha256: 9df0c821325dfe63a6e97c6e77ceb71a42ee7dfb207f5e03e1743546edf2c247

Contents?: true

Size: 588 Bytes

Versions: 2

Compression:

Stored size: 588 Bytes

Contents

# https://circleci.com/docs/environment-variables
require 'uri'

module Danger
  module CISource
    class CircleCI < CI
      def self.validates?(env)
        return !env["CIRCLE_BUILD_NUM"].nil? &&
          !env["CI_PULL_REQUEST"].nil? &&
          URI.parse(env["CI_PULL_REQUEST"]).path.split("/").count == 5
      end

      def initialize(env)
        paths = URI.parse(env["CI_PULL_REQUEST"]).path.split("/")
        # The first one is an extra slash, ignore it
        self.repo_slug = paths[1] + "/" + paths[2]
        self.pull_request_id = paths[4]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
danger-0.2.1 lib/danger/ci_source/circle.rb
danger-0.2.0 lib/danger/ci_source/circle.rb