prontolabs/pronto

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

Summary

Maintainability
A
0 mins
Test Coverage
B
81%
module Pronto
  module Formatter
    class CommitFormatter < GitFormatter
      def existing_comments(messages, client, _)
        shas = messages.map(&:commit_sha)
        comments = shas.flat_map { |sha| client.commit_comments(sha) }
        grouped_comments(comments)
      end

      def submit_comments(client, comments)
        comments.each { |comment| client.create_commit_comment(comment) }
      rescue Octokit::UnprocessableEntity, HTTParty::Error => e
        $stderr.puts "Failed to post: #{e.message}"
        $stderr.puts e.inspect
      end
    end
  end
end