Sha256: acea086451fbb5608fbde9cfee45f4ab9fd28f58e15a586a34533cd6f4b8f283

Contents?: true

Size: 975 Bytes

Versions: 6

Compression:

Stored size: 975 Bytes

Contents

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

        # https://developer.github.com/v3/repos/comments/#create-a-commit-comment
        def report(messages, options)
          repo_path = '.'
          repo = ::Saddler::Reporter::Support::Git::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?
          comment = Comment.new(sha, body, path = nil, position = nil)

          # 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

6 entries across 6 versions & 1 rubygems

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