Sha256: f5902f1ed73309f9f2eb37873fd85d0694fca2b54d384480de323eced9c86bd1
Contents?: true
Size: 922 Bytes
Versions: 5
Compression:
Stored size: 922 Bytes
Contents
# frozen_string_literal: true require 'circlemator/pr_finder' module Circlemator class PrCommenter 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 def comment(text) _, pr_url = PrFinder.new(@opts).find_pr raise 'PR not found!' unless pr_url response = @github_repo.post "#{pr_url}/reviews", body: { commit_id: @sha, body: text, event: 'COMMENT', }.to_json if response.code != 200 body = JSON.parse(response.body) raise "PR Comment Failed: #{body.fetch('message')}" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems