class Saddler::Reporter::Github::PullRequestReviewComment

Public Instance Methods

report(messages, _options) click to toggle source

@param messages [String] checkstyle string @param _options [Hash]

@return [void]

@see developer.github.com/v3/pulls/comments/#create-a-comment

# File lib/saddler/reporter/github/pull_request_review_comment.rb, line 14
def report(messages, _options)
  repo_path = '.'
  repo = Repository.new(repo_path)

  data = parse(messages)
  client = Client.new(repo)
  # fetch pull_request_review_comments
  pull_request_review_comments = client.pull_request_review_comments

  patches = client.pull_request_patches

  # build comment
  comments = build_comments_with_patches(data, patches)
  return if comments.empty?

  posting_comments = comments - pull_request_review_comments
  return if posting_comments.empty?

  # create pull_request_review_comments
  posting_comments.each do |posting|
    client.create_pull_request_review_comment(posting)
  end
end