Class: Saddler::Reporter::Github::PullRequestComment

Inherits:
Object
  • Object
show all
Includes:
Helper, Support
Defined in:
lib/saddler/reporter/github/pull_request_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.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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