Sha256: 1adbc3971a05f51c721e3e350898726de908642d95c6c5297da418ff2d229e68
Contents?: true
Size: 1.08 KB
Versions: 4
Compression:
Stored size: 1.08 KB
Contents
module Pronto module Formatter class GithubPullRequestFormatter def format(messages, repo) messages = messages.uniq { |message| [message.msg, message.line.new_lineno] } client = Github.new(repo) commit_messages = messages.map do |message| body = message.msg path = message.path commits = repo.commits_until(message.commit_sha) line = nil sha = commits.find do |commit| patches = repo.show_commit(commit) line = patches.find_line(message.full_path, message.line.new_lineno) line end create_comment(client, sha, body, path, line.position) end "#{commit_messages.compact.count} Pronto messages posted to GitHub" end private def create_comment(client, sha, body, path, position) comment = Github::Comment.new(sha, body, path, position) comments = client.pull_comments(sha) existing = comments.any? { |c| comment == c } client.create_pull_comment(comment) unless existing end end end end
Version data entries
4 entries across 4 versions & 1 rubygems