Sha256: 682b90fdc46223355076a68a14e81688203674b03f7fd1e0e645f7b6f3a546bb

Contents?: true

Size: 1.14 KB

Versions: 8

Compression:

Stored size: 1.14 KB

Contents

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

        # @param messages [String] checkstyle string
        # @param options [Hash]
        # @option options [String] sha target commit sha
        #
        # @return [void]
        #
        # @see https://developer.github.com/v3/repos/comments/#create-a-commit-comment
        def report(messages, options)
          repo_path = '.'
          repo = Repository.new(repo_path)

          sha = options['sha'] || repo.head.sha
          data = parse(messages)

          client = Client.new(repo)
          # fetch commit_comments
          commit_comments = client.commit_comments(sha)

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

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

          # compare commit_comments.include?(comment)
          return if commit_comments.include?(comment)
          # create commit_comment
          client.create_commit_comment(comment)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
saddler-reporter-github-2.1.0 lib/saddler/reporter/github/commit_comment.rb
saddler-reporter-github-2.0.0 lib/saddler/reporter/github/commit_comment.rb
saddler-reporter-github-1.0.0 lib/saddler/reporter/github/commit_comment.rb
saddler-reporter-github-0.4.0 lib/saddler/reporter/github/commit_comment.rb
saddler-reporter-github-0.3.0 lib/saddler/reporter/github/commit_comment.rb
saddler-reporter-github-0.2.2 lib/saddler/reporter/github/commit_comment.rb
saddler-reporter-github-0.2.1 lib/saddler/reporter/github/commit_comment.rb
saddler-reporter-github-0.2.0 lib/saddler/reporter/github/commit_comment.rb