Class: Saddler::Reporter::Github::CommitComment

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

Instance Method Summary collapse

Methods included from Helper

#build_comments_with_patches, #concat_body

Instance Method Details

#report(messages, options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/saddler/reporter/github/commit_comment.rb', line 9

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