Sha256: 0dc1dcebe85e4342bba624fae632e70de29f1a9f6b60d8891b5f4d4f8b3a90f7

Contents?: true

Size: 643 Bytes

Versions: 6

Compression:

Stored size: 643 Bytes

Contents

module Danger
  class RemoteFinder
    def initialize(github_host, remote_logs)
      @github_host = github_host
      @remote_logs = remote_logs
    end

    def call
      remote_url_matches && remote_url_matches["repo_slug"]
    end

    private

    attr_reader :remote_logs, :github_host

    # @return [String] The remote URL
    def remote
      @remote ||= remote_logs.lines.grep(/Fetch URL/)[0].split(": ".freeze, 2)[1]
    end

    # @return [nil / MatchData] MatchData object or nil if not matched
    def remote_url_matches
      remote.match(%r{#{Regexp.escape github_host}(:|/)(?<repo_slug>.+/.+?)(?:\.git)?$})
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
danger-3.5.0 lib/danger/ci_source/support/remote_finder.rb
danger-3.4.2 lib/danger/ci_source/support/remote_finder.rb
danger-3.4.1 lib/danger/ci_source/support/remote_finder.rb
danger-3.4.0 lib/danger/ci_source/support/remote_finder.rb
danger-3.3.2 lib/danger/ci_source/support/remote_finder.rb
danger-3.3.1 lib/danger/ci_source/support/remote_finder.rb