class BuPr::Handlers::Github
Attributes
base[R]
current[R]
linker[R]
repo[R]
title[R]
token[R]
Public Class Methods
call(config:, current_branch: new( config: config, current_branch: current_branch)
click to toggle source
Entry point
@option [BuPr::Configuration] :config @option [String] :current_branch
# File lib/bu_pr/handlers/github.rb, line 20 def self.call config:, current_branch: new( config: config, current_branch: current_branch ).call end
new(config:, current_branch: @current = current_branch)
click to toggle source
@option [BuPr::Configuration] :config @option [String] :current_branch
# File lib/bu_pr/handlers/github.rb, line 29 def initialize config:, current_branch: @current = current_branch @base = config.branch @repo = config.repo @title = config.title @token = config.token end
Public Instance Methods
call()
click to toggle source
# File lib/bu_pr/handlers/github.rb, line 37 def call diff_comment create_pull_request end
create_pull_request()
click to toggle source
@return [Integer] pull-request ID
# File lib/bu_pr/handlers/github.rb, line 42 def create_pull_request res = client.create_pull_request \ repo, base, current, title res[:number] end
diff_comment(pr_number)
click to toggle source
@param pr_number [Integer]
# File lib/bu_pr/handlers/github.rb, line 53 def diff_comment pr_number load_linker pr_number linker.add_comment repo, pr_number, comment_content end
Private Instance Methods
client()
click to toggle source
@private @return [Octokit::Client]
# File lib/bu_pr/handlers/github.rb, line 62 def client @client ||= ::Octokit::Client.new access_token: token end
comment_content()
click to toggle source
@private @return [String]
# File lib/bu_pr/handlers/github.rb, line 68 def comment_content "#{linker.make_compare_links.to_a.join("\n")}" end
load_linker(pr_number)
click to toggle source
@private @return [CompareLinker]
# File lib/bu_pr/handlers/github.rb, line 74 def load_linker pr_number ENV['OCTOKIT_ACCESS_TOKEN'] = token @linker = ::CompareLinker.new repo, pr_number @linker.formatter = ::CompareLinker::Formatter::Markdown.new @linker end