class Circlemator::PrFinder
Public Class Methods
new(github_repo:, base_branch:, compare_branch:, sha:, **_opts)
click to toggle source
# File lib/circlemator/pr_finder.rb, line 12 def initialize(github_repo:, base_branch:, compare_branch:, sha:, **_opts) @github_repo = github_repo @base_branch = base_branch @compare_branch = compare_branch @sha = sha end
Public Instance Methods
find_pr()
click to toggle source
# File lib/circlemator/pr_finder.rb, line 19 def find_pr response = @github_repo.get '/pulls', query: { base: @base_branch } if response.code != 200 raise BadResponseError, response end prs = JSON.parse(response.body) target_pr = prs.find do |pr| pr.fetch('head').fetch('ref') == @compare_branch && pr.fetch('head').fetch('sha') == @sha && pr.fetch('base').fetch('ref') == @base_branch end return if target_pr.nil? [target_pr.fetch('number'), target_pr.fetch('url')] end