class Ruboty::GithubPrRelease::Actions::UpdateRelease

Private Instance Methods

create() click to toggle source
# File lib/ruboty/github_pr_release/actions/update_release.rb, line 8
def create
  message.reply("Updated #{pull_request.html_url}")
rescue Octokit::Unauthorized
  message.reply("Failed in authentication (401)")
rescue Octokit::NotFound
  message.reply("Could not find that repository")
rescue => exception
  message.reply("Failed by #{exception.class} #{exception}")
rescue NoPrExistsError => e
  message.reply(e)
end
message_diff(what, old, new) click to toggle source
# File lib/ruboty/github_pr_release/actions/update_release.rb, line 33
def message_diff(what, old, new)
  diff = Diffy::Diff.new(old, new)
  if
    Ruboty.logger.debug("updating #{what}:\n#{diff.to_s(:color)}\n")
    message.reply("updating #{what}:\n#{diff.to_s.gsub(/\\ No newline at end of file\n/, '')}\n") unless diff.to_s.empty?
  end
end
pull_request() click to toggle source
# File lib/ruboty/github_pr_release/actions/update_release.rb, line 20
def pull_request
  Ruboty.logger.debug("repo: #{repository}")
  Ruboty.logger.debug("base: #{base}")
  Ruboty.logger.debug("from_branch (head): #{from_branch}")
  Ruboty.logger.debug("title: #{title}")
  current_pr = current_pull_request
  raise NoPrExistsError, "Pull Request does NOT exist" if current_pr.empty? 
  b = body
  message_diff('title', current_pr.first.title, title)
  message_diff('body', current_pr.first.body, b)
  client.update_pull_request(repository, current_pr.first.number, title: title, body: b)
end