class Cp8Cli::Github::PullRequest
Attributes
body[R]
expand[R]
from[R]
html_url[R]
title[R]
to[R]
Public Class Methods
create(attributes = {})
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 9 def self.create(attributes = {}) new(**attributes).save end
find_by(repo:, branch:)
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 13 def self.find_by(repo:, branch:) client.pull_requests(repo.shorthand, head: "#{repo.user}:#{branch}").map do |data| new(**data) end.first end
new(from: nil, to: nil, title: nil, body: nil, expand: 1, html_url: nil, **attributes)
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 19 def initialize(from: nil, to: nil, title: nil, body: nil, expand: 1, html_url: nil, **attributes) @from = from @to = to || default_branch @title = title @body = body @expand = expand @html_url = html_url end
Public Instance Methods
open()
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 28 def open Command.open_url(url) end
save()
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 32 def save client.create_pull_request( repo.shorthand, to, from, title, body, draft: true, accept: "application/vnd.github.shadow-cat-preview" # waiting for https://github.com/octokit/octokit.rb/pull/1114 ) end
Private Instance Methods
base_query()
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 64 def base_query { title: title, body: body, expand: expand }.compact.to_query end
base_url()
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 60 def base_url repo.url + "/compare/#{escape to}...#{escape from}" end
default_branch()
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 48 def default_branch client.repo(repo.shorthand).default_branch end
escape(text)
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 72 def escape(text) CGI.escape(text.to_s.strip) end
new_pr_url()
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 56 def new_pr_url "#{base_url}?#{base_query}" end
repo()
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 76 def repo @_repo ||= Repo.current end
url()
click to toggle source
# File lib/cp8_cli/github/pull_request.rb, line 52 def url html_url || new_pr_url end