Class: Saddler::Reporter::Github::CommitReviewComment

Inherits:
Object
  • Object
show all
Includes:
Helper, Support
Defined in:
lib/saddler/reporter/github/commit_review_comment.rb

Instance Method Summary collapse

Methods included from Helper

#build_comments_with_patches, #concat_body

Instance Method Details

#report(messages, options) ⇒ void

This method returns an undefined value.

Parameters:

  • messages (String)

    checkstyle string

  • options (Hash)

Options Hash (options):

  • sha (String)

    target commit sha

See Also:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/saddler/reporter/github/commit_review_comment.rb', line 17

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)

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

  posting_comments = comments - commit_comments
  return if posting_comments.empty?
  # create commit_comment
  posting_comments.each do |posting|
    client.create_commit_comment(posting)
  end
end