class Circlemator::SelfMerger

Constants

MESSAGE

Public Class Methods

new(opts) click to toggle source
# File lib/circlemator/self_merger.rb, line 8
def initialize(opts)
  github_repo = opts.fetch(:github_repo)
  raise "#{github_repo} is invalid" unless github_repo.is_a? GithubRepo

  @github_repo = github_repo
  @sha = opts.fetch(:sha)
  @opts = opts
end

Public Instance Methods

merge!() click to toggle source
# File lib/circlemator/self_merger.rb, line 17
def merge!
  pr_number, pr_url = PrFinder.new(@opts).find_pr
  return if pr_number.nil? || pr_url.nil?

  response = @github_repo.put "#{pr_url}/merge",
                              body: { commit_message: MESSAGE, sha: @sha }.to_json
  if response.code != 200
    body = JSON.parse(response.body)
    raise "Merge failed: #{body.fetch('message')}"
  end
end