Sha256: 63ae55dd3f4eda9f7289e7da711b1789432bc2ff28ac22dce62dc6f11e76d1fc

Contents?: true

Size: 656 Bytes

Versions: 172

Compression:

Stored size: 656 Bytes

Contents

require "danger/ci_source/support/repo_info"

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

    def call
      matched = remote.match(regexp)

      if matched
        RepoInfo.new(matched["repo_slug"], nil)
      end
    end

    private

    attr_reader :remote_logs, :github_host

    def remote
      remote_logs.lines.grep(/Fetch URL/)[0].split(": ".freeze, 2)[1]
    end

    def regexp
      %r{
        #{Regexp.escape(github_host)}
        (:|/|(:/))
        (?<repo_slug>[^/]+/.+?)
        (?:\.git)?$
      }x
    end
  end
end

Version data entries

172 entries across 172 versions & 2 rubygems

Version Path
danger-4.0.5 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-4.0.4 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-4.0.3 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-4.0.2 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-4.0.1 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-4.0.0 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-3.6.0 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-3.5.5 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-3.5.4 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-3.5.3 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-3.5.2 lib/danger/ci_source/support/find_repo_info_from_logs.rb
danger-3.5.1 lib/danger/ci_source/support/find_repo_info_from_logs.rb