Sha256: 6d3d0384d3d477628a8df3759916f9dd5c7420a710da85ff0029d0613f6c204d

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

# coding: utf-8

require "danger/helpers/comments_helper"
require "danger/helpers/comment"

module Danger
  module RequestSources
    class LocalOnly < RequestSource
      include Danger::Helpers::CommentsHelper
      attr_accessor :mr_json, :commits_json

      def self.env_vars
        ["DANGER_LOCAL_ONLY"]
      end

      def initialize(ci_source, _environment)
        self.ci_source = ci_source
      end

      def validates_as_ci?
        true
      end

      def validates_as_api_source?
        true
      end

      def scm
        @scm ||= GitRepo.new
      end

      def setup_danger_branches
        # Check that discovered values really exists
        [ci_source.base_commit, ci_source.head_commit].each do |commit|
          raise "Specified commit '#{commit}' not found" if scm.exec("rev-parse --quiet --verify #{commit}").empty?
        end

        self.scm.exec "branch #{EnvironmentManager.danger_base_branch} #{ci_source.base_commit}"
        self.scm.exec "branch #{EnvironmentManager.danger_head_branch} #{ci_source.head_commit}"
      end

      def fetch_details; end

      def update_pull_request!(_hash_needed); end

      # @return [String] The organisation name, is nil if it can't be detected
      def organisation
        nil
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
danger-9.1.0 lib/danger/request_sources/local_only.rb
danger-9.0.0 lib/danger/request_sources/local_only.rb
danger-8.6.1 lib/danger/request_sources/local_only.rb
danger-8.6.0 lib/danger/request_sources/local_only.rb
danger-8.5.0 lib/danger/request_sources/local_only.rb
danger-8.4.5 lib/danger/request_sources/local_only.rb