-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #16
- Loading branch information
Showing
10 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Pronto | ||
module Formatter | ||
class GithubPullRequestFormatter | ||
def format(messages, repo) | ||
commit_messages = messages.map do |message| | ||
github_slug = repo.github_slug | ||
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 | ||
|
||
position = line.position - 1 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mmozuras
Author
Member
|
||
|
||
comment = Github::Comment.new(github_slug, sha, body, path, position) | ||
create_comment(github_slug, sha, comment) | ||
end | ||
|
||
"#{commit_messages.compact.count} Pronto messages posted to GitHub" | ||
end | ||
|
||
private | ||
|
||
def create_comment(repo, sha, comment) | ||
comments = client.pull_comments(repo, sha) | ||
existing = comments.any? { |c| comment == c } | ||
client.create_pull_comment(repo, sha, comment) unless existing | ||
end | ||
|
||
def client | ||
@client ||= Github.new | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Are you sure comment should be posted one line before? Why?