Class: Pronto::Formatter::GithubPullRequestFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/pronto/formatter/github_pull_request_formatter.rb

Instance Method Summary collapse

Instance Method Details

#format(messages, repo, patches) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pronto/formatter/github_pull_request_formatter.rb', line 4

def format(messages, repo, patches)
  client = Github.new(repo)
  head = repo.head_commit_sha

  commit_messages = messages.uniq.map do |message|
    body = message.msg
    path = message.path
    line = patches.find_line(message.full_path, message.line.new_lineno)

    create_comment(client, head, body, path, line.position)
  end

  "#{commit_messages.compact.count} Pronto messages posted to GitHub"
end