class Saddler::Reporter::Github::PullRequestComment

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/issues/comments/#create-a-comment

# File lib/saddler/reporter/github/pull_request_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_comments(issue)
  pull_request_comments = client.issue_comments

  # build comment
  body = concat_body(data)
  return if body.empty?

  sha = nil
  path = nil
  position = nil
  comment = Comment.new(sha, body, path, position)

  # compare pull_request_comments.include?(comment)
  return if pull_request_comments.include?(comment)
  # create pull_request_comment
  client.create_issue_comment(comment)
end