class Deodorant::Github
Constants
- OCTOKIT_CLIENT_NEW
Public Class Methods
new(octokit: nil, git_client: nil)
click to toggle source
# File lib/deodorant/github.rb, line 8 def initialize(octokit: nil, git_client: nil) @octokit = octokit || OCTOKIT_CLIENT_NEW @git_client = git_client || Repo.default_git_client end
Public Instance Methods
append_change_id_to_pr(pr_number:, change_id:)
click to toggle source
# File lib/deodorant/github.rb, line 40 def append_change_id_to_pr(pr_number:, change_id:) pr = pull_request(number: pr_number) unless pr.body.include?(change_id) new_body = pr.body << "\n\nChange-Id: #{change_id}" @octokit.update_pull_request(github_repo, pr_number, body: new_body) end end
comments(pr_number:)
click to toggle source
# File lib/deodorant/github.rb, line 27 def comments(pr_number:) review_comments = pull_request(pr_number).rels[:review_comments].get.data comms = review_comments.map do |c| com = Comment.new com.github_id = c.id com.path = c.path com.line = c.position com.message = c.body com.author = c.user.login end comms end
pull_request(number:)
click to toggle source
# File lib/deodorant/github.rb, line 23 def pull_request(number:) @octokit.pull_request(github_repo, number) end
pull_requests(state: 'open')
click to toggle source
# File lib/deodorant/github.rb, line 19 def pull_requests(state: 'open') @octokit.pull_requests(github_repo, state: state) end
update_github()
click to toggle source
# File lib/deodorant/github.rb, line 14 def update_github @git_client.fetch('gerrit') @git_client.push('github', 'gerrit/master:refs/heads/master') end
Private Instance Methods
github_repo()
click to toggle source
# File lib/deodorant/github.rb, line 50 def github_repo @github_rebo ||= begin url = @git_client.remote('github').url URI.parse(url).path.gsub(%r{^\/}, '') end end