Sha256: 309117adf14cb88246e2f51df8e0308d8ad0ed2f25eb550333f748939becc125

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

module Saddler
  module Reporter
    module Github
      class PullRequestReviewComment
        include ::Saddler::Reporter::Support
        include Helper

        # https://developer.github.com/v3/pulls/comments/#create-a-comment
        def report(messages, _options)
          repo_path = '.'
          repo = ::Saddler::Reporter::Support::Git::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
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
saddler-reporter-github-0.1.5 lib/saddler/reporter/github/pull_request_review_comment.rb
saddler-reporter-github-0.1.4 lib/saddler/reporter/github/pull_request_review_comment.rb
saddler-reporter-github-0.1.3 lib/saddler/reporter/github/pull_request_review_comment.rb
saddler-reporter-github-0.1.2 lib/saddler/reporter/github/pull_request_review_comment.rb
saddler-reporter-github-0.1.1 lib/saddler/reporter/github/pull_request_review_comment.rb
saddler-reporter-github-0.1.0 lib/saddler/reporter/github/pull_request_review_comment.rb