prontolabs/pronto

View on GitHub
lib/pronto/formatter/github_combined_status_formatter.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
require_relative 'github_status_formatter/status_builder'

module Pronto
  module Formatter
    class GithubCombinedStatusFormatter < Base
      def self.name
        'github_combined_status'
      end

      def format(messages, repo, _)
        client = Github.new(repo)
        head = repo.head_commit_sha

        create_status(client, head, messages.uniq || [])
      end

      private

      def create_status(client, sha, messages)
        builder = GithubStatusFormatter::StatusBuilder.new(nil, messages)
        status = Status.new(sha, builder.state,
                            'pronto', builder.description)

        client.create_commit_status(status)
      end
    end
  end
end

Pronto::Formatter.register(Pronto::Formatter::GithubCombinedStatusFormatter)